WC_Product_Data_Store_Interface::update_product_stock()publicWC 1.0

Update a product's stock amount directly.

Uses queries rather than update_post_meta so we can do this in one query (to avoid stock issues).

Method of the class: WC_Product_Data_Store_Interface{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Product_Data_Store_Interface = new WC_Product_Data_Store_Interface();
$WC_Product_Data_Store_Interface->update_product_stock( $product_id_with_stock, $stock_quantity, $operation );
$product_id_with_stock(int) (required)
Product ID.
$stock_quantity(int|null)
Stock quantity to update to.
Default: null
$operation(string)
Either set, increase or decrease.
Default: 'set'

WC_Product_Data_Store_Interface::update_product_stock() code WC 8.6.1

public function update_product_stock( $product_id_with_stock, $stock_quantity = null, $operation = 'set' );