0
votes

In Shopify, there is an inventory_quantity attribute tied to a variant that describes how much of an item is left in stock at any given point.

I noticed the following behavior that looks inconsistent to me:

The variant attribute inventory_quantity is updated when the value is modified directly form the Shopify admin, triggering a Product/update webhook.

However, when someone orders that item, Shopify automatically decrements the item's quantity but does not trigger a Product/update Webhook.

Is that a bug or the expected behavior? (In which case, what it the best way to stay in synch with inventory_quantity values?)

1
Probably it doesn't fire the product/update webhook because the inventory_quantity belongs to the ProductVariant (a separate object). But ProductVariant's don't support webhooks. As a workaround you could register to the order/created webhook.hjblok
What puzzles me is that when a variant attribute (like price, variant title and even inventory_quantity) is modified using the Shopify admin and clicking save, a product/update webhook is triggered. Problems arise when the inventory_quantity is modified due to the customers purchasing stuff (in which case a order/create webhook is issued but not a product/update one). I was wondering if it was intentional or not as when you subscribe to product/update you kind of expect a webhook to be issued when an attribute changes, whether it's due to an action of the shop admin or the customer.Daniel Ristic
Yes, you're right. When admin changes to ProductVariants do trigger the product/update webhook, I don't see why it shouldn't for (backend) inventory updates.hjblok

1 Answers

1
votes

This one is expected behavior, whatever you want the same thing I have used in my case. And When order/create webhook is available then product/udpate shouldn't be sent due to dual requests which make confusing to our code side.

Use following to sync inventory-

  1. order/create
  2. product/update