Solved

Inventory Changes & Product/Update Webhook Triggers

pmooney-extend
Tourist
3 0 10

Hello,

We provide a Shopify App to enable Shopify merchants to sell extended warranties for their products. Part of the process in providing this service to merchants is to ensure we have an accurate representation of the variants in a merchant's Shopify store. As part of our integration, we add a webhook for the `product/update` topic that POSTs to our endpoint to see if there are price changes for the variant we need to account for when we offer the extended warranty.

However, we noticed that there is an influx of webhook `product/update` requests coming into our system when we do this. After investigating, it seems that every time an order is made on a product that is inventory-tracked, the webhook is called, since Shopify seems to consider this a "product" update.

Therefore, I have the following questions:

1. Is there some way we can only receive a webhook request from Shopify when just the product's fields are changed (such as description, price, title, etc.), and not inventory?

2. Is there a way to tell in the 'product/update' webhook request body what field changed, so we can decide whether or not this webhook is actionable on our part? Preferably the solution would not involve managing our own version of the merchant's Shopify product catalog and querying against our database every time to compare fields and see what changed.

3. If the answers to questions 1. and 2. are no, is there anything on the developer roadmap to change the behavior of these webhooks to conform to the requests I spelled out here?

Accepted Solution (1)

james-langille
Shopify Staff (Retired)
70 15 27

This is an accepted solution.

Hello @pmooney-extend, to answer your questions:

  1. Currently, no. Webhooks are fired whenever a model is created, deleted, or anything within it is changed, including the inventory level for products.
  2. Currently, no. Update webhooks only report the current state of the model, not what field(s) changed. I agree something like that would be useful, and it's not ideal to ask apps to track their own state to figure out what changed.
  3. Yes. Although I cannot commit to any timelines here, we are currently looking at different alternatives to make Webhooks more relevant to downstream apps. We aim to strike a balance between complexity and relevance to simplify application development.

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 15 (15)

james-langille
Shopify Staff (Retired)
70 15 27

This is an accepted solution.

Hello @pmooney-extend, to answer your questions:

  1. Currently, no. Webhooks are fired whenever a model is created, deleted, or anything within it is changed, including the inventory level for products.
  2. Currently, no. Update webhooks only report the current state of the model, not what field(s) changed. I agree something like that would be useful, and it's not ideal to ask apps to track their own state to figure out what changed.
  3. Yes. Although I cannot commit to any timelines here, we are currently looking at different alternatives to make Webhooks more relevant to downstream apps. We aim to strike a balance between complexity and relevance to simplify application development.

To learn more visit the Shopify Help Center or the Community Blog.

gdarrigo
Tourist
4 0 5

There is some news to check if the update is due to inventory change?

Thanks

Gabriele

james-langille
Shopify Staff (Retired)
70 15 27

Sadly, no. However, there are more topics you can listen to that are inventory-specific if that helps, such as 'inventory_levels/update' or 'inventory_items/update'

To learn more visit the Shopify Help Center or the Community Blog.

gdarrigo
Tourist
4 0 5

My goal is to filter the events due to inventory update and keep only others, cause I have hundreds of update events that I don't need and that give me a lot of unusefull traffic that send my system in crysis. Can you give some advice to solve?

Thanks

Gabriele

cYberSport91
Tourist
8 0 2

The variants seem to have `old_inventory_quantity` alongside with `inventory_quantity`. 

If you update a product in Shopify Admin, and Product Update webhook gets fired, and all the quantities are the same - could you safely assume that you updated something outside of quantity?

If an order is placed, it seems safe to assume the only thing that's going to change is an inventory.

If so, a very simple serverless function could solve this in ~10 LOC

pmooney-extend
Tourist
3 0 10

We noticed this too @cYberSport91 , but when testing this same concept in our lambda, for whatever reason, Shopify was ALWAYS returning the same value for old_inventory_quantity and inventory_quantity  🤕. We were gonna report it as a bug, but then we saw in their API documentation that these fields are deprecated and will be removed, so it wouldn't have been a long-term solution for us anyways.

cYberSport91
Tourist
8 0 2

@pmooney-extend noooo.  dang.  do you have a solution you've come up with?  I'm hacking on a rails proxy to just cache everything and trigger the netlify rebuilds for me. 

pmooney-extend
Tourist
3 0 10

@cYberSport91 No solution yet. Hoping Shopify ( cc @james-langille ) addresses this common use case.

JoshHighland
Shopify Expert
175 10 65

I'm also looking for this solution and have a lambda checking the inventory changes - but as you pointed out the numbers are always the same 😞

SEO Manager - The FREE all-in-One SEO solution for Shopify
A powerful suite of SEO tools that gets you found in Google results

- Install SEO Manager -
cYberSport91
Tourist
8 0 2

Yeah you'll have to attach some sort of database to compare with.  I built a crap thing in Rails that seems to somewhat work but would be really nice to have a redis/node open source solution we can all contribute to

marco_rojo
Visitor
1 0 0

Is there some news about this subject? All my products are not marked to track the quantity, but still, the trigger is being fired. This is causing a lot of problems like unwanted metafields fetching, which in turn results in `Too Many Requests (Exceeded 4 calls per second for api client. Reduce request rates to resume uninterrupted service.).`

 

Thanks

JoshHighland
Shopify Expert
175 10 65

I added this question into the upcoming Shopify town hall. Please upvote it

https://app.sli.do/event/88Kroj7brZ7AMeqCB3ZnXN/live/questions

SEO Manager - The FREE all-in-One SEO solution for Shopify
A powerful suite of SEO tools that gets you found in Google results

- Install SEO Manager -
shaswa
New Member
4 0 0

@JoshHighland I was not able to attend the Shopify town hall. Was this addressed during the town hall?

ldrolez
Shopify Partner
1 0 0

Some news about this feature? Thanks

JoshHighland
Shopify Expert
175 10 65

I added this question the the upcoming Shopify town hall. Please go upvote it so we can get some traction on it.

 

https://app.sli.do/event/88Kroj7brZ7AMeqCB3ZnXN/live/questions

 

SEO Manager - The FREE all-in-One SEO solution for Shopify
A powerful suite of SEO tools that gets you found in Google results

- Install SEO Manager -