WC_Meta_Box_Product_Reviews::save()public staticWC 1.0

Save meta box data

{} It's a method of the class: WC_Meta_Box_Product_Reviews{}

No Hooks.

Return

Mixed.

Usage

$result = WC_Meta_Box_Product_Reviews::save( $data );
$data(mixed) (required)
Data to save.

Code of WC_Meta_Box_Product_Reviews::save() WC 6.7.0

public static function save( $data ) {
	// Not allowed, return regular value without updating meta.
	if ( ! isset( $_POST['woocommerce_meta_nonce'], $_POST['rating'] ) || ! wp_verify_nonce( wp_unslash( $_POST['woocommerce_meta_nonce'] ), 'woocommerce_save_data' ) ) { // WPCS: input var ok, sanitization ok.
		return $data;
	}

	if ( $_POST['rating'] > 5 || $_POST['rating'] < 0 ) { // WPCS: input var ok.
		return $data;
	}

	$comment_id = $data['comment_ID'];

	update_comment_meta( $comment_id, 'rating', intval( wp_unslash( $_POST['rating'] ) ) ); // WPCS: input var ok.

	// Return regular value after updating.
	return $data;
}