Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Webhook sending previous and new inventory level

Solved

Webhook sending previous and new inventory level

gubstav
Tourist
4 1 0

Hi,

 

I'm in the process of building an integration with Shopify in my web application.

And I need to be able to see, when a product is updated, the previous and new inventory level for that product.

I can see that the 'products/update' webhook topic sends 'inventory_quantity' and 'old_inventory_quantity', however, 'old_inventory_quantity' is deprecated...

 

Is there a way to solve this with any other webhook topic, for example the topic 'inventory_items/update'?

 

I need:

– The new inventory level of a product variant

– The previous inventory level of a product variant

– OR the change / delta in inventory level of a product variant

 

Kind regards,

Gus

Accepted Solution (1)

gubstav
Tourist
4 1 0

This is an accepted solution.

I ended up solving my problem by using the orders/paid webhook and using the ‘quantity’ field for each variant.

 

Shopify should add ‘inventory_change’ to the inventory_level update webhook.

View solution in original post

Replies 4 (4)

KB77
Shopify Staff
59 6 11

Hi @gubstav I believe the webhook you would use here is 

inventory_levels/update

to see the currently available inventory https://shopify.dev/api/admin-rest/2022-04/resources/webhook

KB77 | API 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

gubstav
Tourist
4 1 0

Hi @KB77,

 

That webhook does not provide the previous inventory level – only the available amount.

gubstav
Tourist
4 1 0

This is an accepted solution.

I ended up solving my problem by using the orders/paid webhook and using the ‘quantity’ field for each variant.

 

Shopify should add ‘inventory_change’ to the inventory_level update webhook.

bbison49
Visitor
3 0 0

Hey, 

 

I am doing something similar. I was hoping the inventory update webhook payload would contain some delta or I could create one with an "old_inventory_level" type property. 

 

I went the same route as you decrementing inventory in my app based on the order created webhook. 

 

However, I'm finding (especially with the "return" functionality) there are more inconsistencies around inverementing/restocking inventory in my app when dealing with cancellations/returns/refunds. 

 

Did you find any consistent way of dealing with that?

 

Thanks!