Prevent average product rating meta from being set for other post types

This commit is contained in:
Chase Wiseman 2016-09-08 09:36:56 -07:00
parent 238483ff2b
commit 51b5d11b97
1 changed files with 7 additions and 4 deletions

View File

@ -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 );
}
}
/**