Will the products/update webhook fire whenever inventory quantity changes?

ClementBR
Shopify Partner
110 2 18

Is it guaranteed that the `products/update` webhook will fire whenever any of its variants `inventory_quantity` changes for any reason?

Such as whenever a variant is bought/refunded (assuming inventory is tracked), whenever the variant's stocked quantity at any location changes, or any other reason?

 

You see, we must keep a local synchronized copy of the total inventory per variant in our local database.

 

Ideally, we would prefer to only have to listen to `products/update` and store the `variant.inventory_quantity` that we receive.

But we are wondering if we must also listen for `orders/create`, 'orders/refunded', 'orders/edited', 'inventory_level/update', etc..., and then query back into the products API when we receive those. Is it necessary?

 

Based on initial basic testing, it seems that products/update indeed fires whenever the inventory quantity changes.

However, it is critical for us to always be in sync perfectly, so I'd really love to get an official answer from someone at Shopify that could confirm. While our testing is looking promising, it seems impossible to test all possible scenarios, including potential programmatic changes done by other third party apps, POS scenarios and any other cases we might not think about.

 

Thank you in advance.

0 Likes
_JB
Shopify Staff
Shopify Staff
750 86 163

Hey @ClementBR,

 

The expected behaviour is for the product#update webhook to fire when the available quantity changes for a variant. I've tested this all the ways I can think of and can confirm the webhook fired in each instance.

 

While it's expected for product#update to fire on inventory changes, it's worth mentioning that Shopify doesn't guarantee the delivery of webhooks 100% of the time. Although our webhooks are generally very reliable it's possible for a webhook delivery to be missed, so we recommend not to use webhooks as the sole source of data for your app. One option is to run a job periodically to fetch resources and check that against your local db, the new BulkOperation API is a great tool to help with this.

JB | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

0 Likes
ClementBR
Shopify Partner
110 2 18

Got it, thank you for your answer.

 

Given that testing all the scenarios is probably unrealistic, would someone be able to check the code to confirm that the webhook will always fire?

0 Likes