WordPress at Your Fingertips
function is not described

WC_Product_Grouped::sync() public WC 1.0

Sync a grouped product with it's children. These sync functions sync upwards (from child to parent) when the variation is saved.

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

No Hooks.

Return

WC_Product. Synced product object.

Usage

$result = WC_Product_Grouped::sync( $product, $save );
$product(WC_Product|int) (required)
Product object or ID for which you wish to sync.
$save(true|false)
If true, the product object will be saved to the DB before returning it.
Default: true

Code of WC_Product_Grouped::sync() WC 5.7.0

public static function sync( $product, $save = true ) {
	if ( ! is_a( $product, 'WC_Product' ) ) {
		$product = wc_get_product( $product );
	}
	if ( is_a( $product, 'WC_Product_Grouped' ) ) {
		$data_store = WC_Data_Store::load( 'product-' . $product->get_type() );
		$data_store->sync_price( $product );
		if ( $save ) {
			$product->save();
		}
	}
	return $product;
}