WC_Comments::clear_transients( int $post_id )

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


Description Description


Parameters Parameters

$post_id

(Required) Post ID.


Top ↑

Source Source

File: includes/class-wc-comments.php

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


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.