Hi there @malw
From what I gather, you are trying to update stock levels on product variations utilizing the WooCommerce REST API.
Could you elaborate further on what you have tried so far, and how, please?
Thank you. 🙂</img>
Thread Starter
malw
(@malw)
Hi,
Correct, it’s the stock levels on product variations.
I am sending this body:
{
"manage_stock": true,
"stock_quantity": 78
}
As PUT to this endpoint: …wp-json/wc/v3/products/2214/variations/2217/
Getting nice response:
…
"manage_stock": true,
"stock_quantity": 78,
"stock_status": "instock",
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"low_stock_amount": null,
…
But when doing get against same endpoint 5 sec later (or instantly) i see old stock:
…
"manage_stock": true,
"stock_quantity": 58,
"stock_status": "instock",
"backorders": "no",
"backorders_allowed": false,
"backordered": false,
"low_stock_amount": null,
…
I am able to update the parent item. I have played around with parent item setup (setting stock to 100, setting to nothing, setting manage stock to false/true) nothing works.
Hello,
You will want to pass these parameters: manage_stock, stock_quantity and stock_status when making the /wp-json/wc/v3/products POST request.
You can check the properties you can send below:
https://woocommerce.github.io/woocommerce-rest-api-docs/#product-properties
More info:
https://woocommerce.github.io/woocommerce-rest-api-docs/#update-a-product
I hope this helps.
Thread Starter
malw
(@malw)
You mean that stock status needs to be added to the body, even though stock status does not change. Since inventory level is positive before and after post.
Thread Starter
malw
(@malw)
Hi,
The problem is solved. The website/shop partner updated woocommerce and maybe wordpress and some other apps. Sorry about the lack of details about this.
The REST call itself is completely the same as before.
-
This reply was modified 3 years, 3 months ago by
malw.
Hi @malw!
Happy to hear that the issue got resolved 🙂