WordPress at Your Fingertips
function is not described

WC_Comments::clear_transients() public WC 1.0

Ensure product average rating and review count is kept up to date.

{} It's a method of the class: WC_Comments{}

No Hooks.

Return

null. Nothing.

Usage

$result = WC_Comments::clear_transients( $post_id );
$post_id(int) (required)
Post ID.

Code of WC_Comments::clear_transients() WC 5.7.1

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();
	}
}