Updating Stock

dashboard
inventory

#1

I created a product with cURL that I can see on my dashboard. If edit the product and try to update the inventory, I get an error that says “There was a problem saving your product”. Is this a normal response?

Also, if I update the inventory in cURL, it does not show up on my dashboard.


#2

Sorry to hear you’re having issues. I’d like to help get you up and running again :slight_smile:

Could you share the payload of the PUT request you’ve sent?


#3

The first thing I tried was adjusting the inventory in Forge once the product was created. The screenshot below shows where I am trying to adjust this. When I do this I get a pop up that says, “There was an error updating your product.”

In cURL I’ve done the following.

  1. Updated the availability to “in-stock.”

stock":{“level”:1,“availability”:“in-stock”}

  1. Incremented the inventory to 10.

{“id”:“b330b6f7-2dee-4bfc-9e6c-d6b86e96fb21”,“type”:"",“total”:10,“available”:10,“allocated”:0}

To update the status I used the following cURL command.

curl -X PUT https://api.moltin.com/v2/products/PRODUCT-ID \
-H "Authorization: Bearer XXXX" \
-H "Content-Type: application/json" \
-d '{"data": {"id":"PRODUCT-ID","type":"product","stock":{"availability":"in-stock"}}}'

To update the inventory I used the following cURL command.

curl -X POST https://api.moltin.com/v2/inventories/PRODUCT-ID/transactions \
  -H "Authorization: Bearer XXXX" \
  -H "Content-Type: application/json" \
  -d '{"data":{"type":"transaction", "action":"incremented","quantity":10}}'

Even after doing this and getting the response that shows a quantity of 10, I see the inventory as 1 in Forge.


#4

The inventories service is not currently functioning fully, so any requests made to that service won’t directly influence product stock as of right now.

The correct payload to update the stock levels on a product would be:

{
  "data": {
    "id": id,
    "stock": 10,
    "type": "product"
  }
}

note: stock is an integer

The meta.stock.availability attribute is returned by the API based on the value of meta.stock.level and cannot be set via the API.

Hope this helps!


#5

Are you able to allocate and decrement inventory? If not do you just reset the inventory when something is sold?


#6

Product inventory will eventually integrate with carts and orders. Meaning when a product sells the API will decrement the stock accordingly.

Unfortunately that is not available at the moment, so it is still a manual process. This inventory integration (with catalogue, carts and orders) is something on our roadmap for early 2018.


#7

Is there a way to tell what is and isn’t active in the docs?


#8

We’re actually working on a new, improved and up-to-date API reference that we hope to have live in the near future :slight_smile:


#9

Hi @jonthornham

The new API reference is now available :tada:

There are some endpoints currently in BETA that are clearly marked.


#10

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.