• Resolved malw

    (@malw)


    I’m trying to update stock levels on product variation using rest api. I use put on the …product/id/variations/Id endpoint, where Get works fine. My body is something like this: {managestock: true, stocklevel: 50}
    The response is 200 with the variant and the new stock level. However when get request again, stock level is same as before.
    data on main product is manage stock true, stock level 100 (also tried with 0).
    what am I doing wrong?

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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 2 years ago by malw.
    Plugin Support Raif D. a11n

    (@rdeari)

    Hi @malw!

    Happy to hear that the issue got resolved ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Stock level stuck on rest api update’ is closed to new replies.