WC_Product_Data_Store_CPT::update_average_rating()publicWC 3.0.0

Update a products average rating meta.

Method of the class: WC_Product_Data_Store_CPT{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Product_Data_Store_CPT = new WC_Product_Data_Store_CPT();
$WC_Product_Data_Store_CPT->update_average_rating( $product );
$product(WC_Product) (required)
Product object.

Changelog

Since 3.0.0 Introduced.

WC_Product_Data_Store_CPT::update_average_rating() code WC 9.4.2

public function update_average_rating( $product ) {
	update_post_meta( $product->get_id(), '_wc_average_rating', $product->get_average_rating( 'edit' ) );
	self::update_visibility( $product, true );
}