WC_Product_Variable_Data_Store_CPT::sync_stock_status()
Sync variable product stock status with children. Change does not persist unless saved by caller.
Method of the class: WC_Product_Variable_Data_Store_CPT{}
No Hooks.
Return
null
. Nothing (null).
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. |
WC_Product_Variable_Data_Store_CPT::sync_stock_status() WC Product Variable Data Store CPT::sync stock status code WC 9.4.2
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' ); } }