wordpress - woocommerce set_stock_quantity not working -


i making plugin update stock quantity of woocommerce it's sort of third party cart want sync quantity of woocommerce other website data. code

$quantity = floatval(5); $product_id = 10; $woocmmerce_instance = new wc_product( $product_id ); $woocmmerce_instance->set_stock_quantity($quantity); 

but throws error php fatal error: call undefined method wc_product::set_stock_quantity()

used wc_update_product_stock() update product's stock amount.

put code in plugin perform operation update product quantity.

global $woocommerce; $quantity = 5; $product_id = 10; $woocmmerce_instance = new wc_product( $product_id ); $new_quantity=wc_update_product_stock( $woocmmerce_instance, $quantity); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -