From 38cd9b4df7886f9b08c7295b24ea1adfc00c774d Mon Sep 17 00:00:00 2001 From: Claudiu Lodromanean Date: Wed, 29 Mar 2017 14:51:33 -0700 Subject: [PATCH] Update product rating counts after adding a rating --- includes/class-wc-comments.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/includes/class-wc-comments.php b/includes/class-wc-comments.php index fa3121c11b3..daaebe840f9 100644 --- a/includes/class-wc-comments.php +++ b/includes/class-wc-comments.php @@ -205,6 +205,11 @@ class WC_Comments { return; } add_comment_meta( $comment_id, 'rating', (int) esc_attr( $_POST['rating'] ), true ); + + $post_id = isset( $_POST['comment_post_ID'] ) ? (int) $_POST['comment_post_ID'] : 0; + if ( $post_id ) { + self::clear_transients( $post_id ); + } } }