Product/update webhook triggered on order placed

Product/update webhook triggered on order placed

Ionuts1
Shopify Partner
24 1 4

Hi, I also have a challenge that I'm trying to overcome and I don't know how I could solve it.
I have 3 stores, with identical products, what I'm trying to do using webhook product/update is to update the products on the other stores.


Example: store 1 is the base store, if I update a product to it, I have a graphql that goes and updates the correct product, all good so far. But the biggest problem for me is the following, when an order is placed on store 1 automatically product/update is triggered and updates the product on the other stores too. I do not want this to happen.

 

Is it possible to identify when the product is updated manually vs when an order has been placed and product/update has been triggered?

Replies 5 (5)

Ionuts1
Shopify Partner
24 1 4

I tried the following scenarios, adding an order/created webhook and when it is triggered I tried to retrieve the timestamp and compare it with product/update which is triggered after an order has been placed.

This scenario is not functional either because sometimes updates can be made to products while orders are being placed.

 

I've also tried with metafield to have a custom metafield with last_changed and every time the product is updated manually to update that field.

The problem with this method is that at order/create you don't get the metafield.

 

How i said, it is much harder to achieve this functionality.

SBD_
Shopify Staff
1831 273 419

Hey @Ionuts1 

 

Just ran some tests with this one. It's tricky because even product.update_at will change when an order is placed.

 

One approach would be to store the properties you care about (title, description, etc) on your server, and compare them before sending an update to the other stores. E.g. if update_at changes, don't do anything - but if title or description changes, process an update.

 

Would love to hear if/how you solve this.

 

Scott | Developer Advocate @ Shopify 

Ionuts1
Shopify Partner
24 1 4

Hi, I managed to solve it with a hack, I have an order/create webhook and when I get this order/create request I get the timestamp and compare it with the next product/update which is with a small difference of 1s/2s max.
Then I made a condition that checks if the order/create and the timestamp from product/update are in this 2-3s range and contain the same product id.

JoshHighland
Shopify Partner
213 12 76

This has been an issue since the webhook topic was introduced. The next API version has webhook sub topics. Im hoping that we will get a sub topic on product update only, not inventory changes.

 

https://shopify.dev/docs/apps/webhooks/sub-topics

 

 

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

- Install SEO Manager -
Ionuts1
Shopify Partner
24 1 4

When is gonna happed this? i mean when they gonna add this, you know? thanks