How to correctly retrieve Shopify inventory levels

128 Views Asked by At

I am trying to build a flow (in a web app) where Shopify shop admins can get notified when the inventory levels for a particular product is below a certain threshold in a particular location. I have looked at the inventory_levels/update webhook but I am in a pickle after reading this.

According to the documentation, the true inventory levels for a location will only be known after the order has been fulfilled. In that case, do I have to subscribe to the orders/fulfilled and order/partially_fulfilled webhooks as well ?

What is the best way to go about it ?

1

There are 1 best solutions below

2
David Lazar On

You can follow a simple recipe like this:

  • listen for an order, and cherry pick the line items sold
  • using the line item, get the variant inventory item ID
  • using the inventory item ID you can get inventory levels

You can get all the locations a shop has, and when you combine a location ID with an inventory item ID, you can get the levels of every SKU at every location

Not a hard recipe at all. Of course, that is one of many. Feel free to try others.