WC_Comments::clear_transients()
Ensure product average rating and review count is kept up to date.
Method of the class: WC_Comments{}
No Hooks.
Return
null
. Nothing (null).
Usage
$result = WC_Comments::clear_transients( $post_id );
- $post_id(int) (required)
- Post ID.
WC_Comments::clear_transients() WC Comments::clear transients code WC 9.4.2
public static function clear_transients( $post_id ) { if ( 'product' === get_post_type( $post_id ) ) { $product = wc_get_product( $post_id ); $product->set_rating_counts( self::get_rating_counts_for_product( $product ) ); $product->set_average_rating( self::get_average_rating_for_product( $product ) ); $product->set_review_count( self::get_review_count_for_product( $product ) ); $product->save(); } }