WordPress at a glance
function is not described

WC_Abstract_Legacy_Product::sync_average_rating() public WC 1.0

Deprecated from version 3.0.0. It is no longer supported and can be removed in future releases. It is recommended to replace this function with the same one.

Sync product rating. Can be called statically.

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

No Hooks.


Null. Nothing.


$result = WC_Abstract_Legacy_Product::sync_average_rating( $post_id );
$post_id(int) (required)


Deprecated 3.0.0

Code of WC_Abstract_Legacy_Product::sync_average_rating() WC 5.0.0

public static function sync_average_rating( $post_id ) {
	wc_deprecated_function( 'WC_Product::sync_average_rating', '3.0', 'WC_Comments::get_average_rating_for_product or leave to CRUD.' );
	// See notes in https://github.com/woocommerce/woocommerce/pull/22909#discussion_r262393401.
	// Sync count first like in the original method https://github.com/woocommerce/woocommerce/blob/2.6.0/includes/abstracts/abstract-wc-product.php#L1101-L1128.
	self::sync_rating_count( $post_id );
	$average = WC_Comments::get_average_rating_for_product( wc_get_product( $post_id ) );
	update_post_meta( $post_id, '_wc_average_rating', $average );