wc_update_product_stock_status( int $product_id, string $status )

Update a product’s stock status.


Description Description


Parameters Parameters

$product_id

(Required) Product ID.

$status

(Required) Status.


Top ↑

Source Source

File: includes/wc-stock-functions.php

function wc_update_product_stock_status( $product_id, $status ) {
	$product = wc_get_product( $product_id );
	if ( $product ) {
		$product->set_stock_status( $status );
		$product->save();
	}
}


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.