From 51b5d11b972274556eaad41147b7dde982ba1de5 Mon Sep 17 00:00:00 2001 From: Chase Wiseman Date: Thu, 8 Sep 2016 09:36:56 -0700 Subject: [PATCH] Prevent average product rating meta from being set for other post types --- includes/class-wc-comments.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/includes/class-wc-comments.php b/includes/class-wc-comments.php index 8249c3f3504..161e99254a1 100644 --- a/includes/class-wc-comments.php +++ b/includes/class-wc-comments.php @@ -236,10 +236,13 @@ class WC_Comments { * @param int $post_id */ public static function clear_transients( $post_id ) { - delete_post_meta( $post_id, '_wc_average_rating' ); - delete_post_meta( $post_id, '_wc_rating_count' ); - delete_post_meta( $post_id, '_wc_review_count' ); - WC_Product::sync_average_rating( $post_id ); + + if ( 'product' === get_post_type( $post_id ) ) { + delete_post_meta( $post_id, '_wc_average_rating' ); + delete_post_meta( $post_id, '_wc_rating_count' ); + delete_post_meta( $post_id, '_wc_review_count' ); + WC_Product::sync_average_rating( $post_id ); + } } /**