WordPress at Your Fingertips
function is not described

WC_Product_Variable_Data_Store_CPT::sync_stock_status() public WC 3.0.0

Sync variable product stock status with children. Change does not persist unless saved by caller.

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

No Hooks.

Return

null. Nothing.

Usage

$WC_Product_Variable_Data_Store_CPT = new WC_Product_Variable_Data_Store_CPT();
$WC_Product_Variable_Data_Store_CPT->sync_stock_status( $product );
$product(WC_Product) (required) (passed by reference — &)
Product object.

Changelog

Since 3.0.0 Introduced.

Code of WC_Product_Variable_Data_Store_CPT::sync_stock_status() WC 6.1.0

public function sync_stock_status( &$product ) {
	if ( $product->child_is_in_stock() ) {
		$product->set_stock_status( 'instock' );
	} elseif ( $product->child_is_on_backorder() ) {
		$product->set_stock_status( 'onbackorder' );
	} else {
		$product->set_stock_status( 'outofstock' );
	}
}