Product rating count doesn't update when ratings are edited by admin is fixed #19581
This commit is contained in:
parent
900c8fc33f
commit
6f36133ed5
|
@ -65,7 +65,7 @@ class WC_Admin_Meta_Boxes {
|
|||
add_action( 'woocommerce_process_shop_coupon_meta', 'WC_Meta_Box_Coupon_Data::save', 10, 2 );
|
||||
|
||||
// Save Rating Meta Boxes.
|
||||
add_action( 'comment_edit_redirect', 'WC_Meta_Box_Product_Reviews::save', 1, 2 );
|
||||
add_filter( 'wp_update_comment_data', 'WC_Meta_Box_Product_Reviews::save', 1, 2 );
|
||||
|
||||
// Error handling (for showing errors from meta boxes on next page load).
|
||||
add_action( 'admin_notices', array( $this, 'output_errors' ) );
|
||||
|
|
|
@ -40,17 +40,18 @@ class WC_Meta_Box_Product_Reviews {
|
|||
/**
|
||||
* Save meta box data
|
||||
*
|
||||
* @param mixed $location
|
||||
* @param int $comment_id
|
||||
* @param mixed $data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function save( $location, $comment_id ) {
|
||||
public static function save( $data ) {
|
||||
// Not allowed, return regular value without updating meta
|
||||
if ( ! wp_verify_nonce( $_POST['woocommerce_meta_nonce'], 'woocommerce_save_data' ) && ! isset( $_POST['rating'] ) ) {
|
||||
return $location;
|
||||
return;
|
||||
}
|
||||
|
||||
$comment_id = $data['comment_ID'];
|
||||
|
||||
// Update meta
|
||||
update_comment_meta(
|
||||
$comment_id,
|
||||
|
@ -59,6 +60,6 @@ class WC_Meta_Box_Product_Reviews {
|
|||
);
|
||||
|
||||
// Return regular value after updating
|
||||
return $location;
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue