How enable/disable WooCommerce product variation using rest API (php)?
-
I cannot figure out how to disable/enable a product variation using the WooCommerce rest api (php). I simply want to replicate the Enable checkbox functionality found when editing a variation through the dashboard, so basically prevent users from purchasing the variation. Using the dashboard checkbox achieves all this, so why can’t I do it using the rest api?
The only public property I can think to change would be ‘purchasable’. So I would have thought that to disable a product variation, this would work (from the docs https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-product-variation):
$woocommerce->put( 'products/103/variations/109', ['purchasable' => false] );
Assuming the product and variation id are correct, which I have tested easily by changing another property like price, why am I not able to change this property?
How am I meant to enable/disable a product variation using the rest API (without using the ‘hack’ of managing stock — I am not managing stock as products are digital)? It seems like such a basic requirement but this value will not change. Even setting the ‘parent’ product to draft does not disable its variations. Thanks for your help.
- The topic ‘How enable/disable WooCommerce product variation using rest API (php)?’ is closed to new replies.