Hello @tahafarooqui
The plugin delivers two endpoints:
/wp-json/wc/v3/products/id
/wp-json/wc/v3/products/id/variations/id (first ID is for parent product, the second one for the variation ID)
Both accept GET and UPDATE requests.
HI, I was using a very basic plugin in php to update my products stock qty from an external XML feed and used
$woocmmerce_instance = wc_get_product( $prodID );
$new_quantity=wc_update_product_stock( $woocmmerce_instance, $quantity);
So now I wanted to use your Get and Update api methods but I’m not familiar on how to do it. Is there any example or any documentation on how I can replace the above mentioned method and use yours to update the stock @ locations?
Also is there a way to programatically assign to my existing products the stock locations?
Thanks in advance!
Hello @jboyoli
You can read more about the WooCommerce REST API here and here.
To assign locations programmatically you need to loop throw all products and use wp_set_object_terms( $post_id, array($location1_id, $location2_id), 'location' ); inside the loop.
how can i update the product quantity using the rest API?
meaning – how should the request look like? (assuming each product have multiple locatioons).
EDIT: managed to solve this issue.
-
This reply was modified 5 years, 5 months ago by
Merav. Reason: solved