Hi, I’d like to implement the following logic:
Webhook for product updates triggers adding a value to the metafield of the updated product, using data from the JSON object provided by the webhook. This should happen on every product update.
I want to track the price history of a product. Can this be achieved within Shopify, or am I forced to create an app with an external endpoint and then redirect the functionality back to Shopify to modify the metafield? I’ve seen that Shopify has a native app called Flow, and it seems this could work there, but there’s no trigger for “Product update,” only for “Product update status,” which doesn’t help me.
I was also considering creating an app using Shopify app init. Still, I’m not quite sure which framework it should be based on, how to capture the webhook, and how to return the action to a database using a mutation query to modify the metafield.
Hey, I am trying to wrap my head around what you would like to achieve. I can see the webhook for product update here Webhooks
I assume a solution would be to create a small shopify app that triggers the webhook on product update then in your backend, the webhook is picked up and using Shopify API make the change.
I am trying to think of a way to leave out the backend framework, perhaps inside of the same call as the webhook you could write to the webhook.
I have been using Shopify Remix lately so whatever I suggest will use the same.
I used Google Cloud Platform as my backend and built the logic using Node.js. The goal was to create a field where I store the product’s price history. I’m using a hook, and then in GCP, I process the data and, based on certain conditions, send it to the appropriate metafield to display the lowest price.
Hey @jamalali81,
If you need the correct answer then I highly recommend to post this question to shopify.dev forum.
In shopify.dev experienced Shopify staff are available to answer your any type of query.
Yes, there is no “product updated” or “variant updated” trigger in Flow.
One reason for this, I believe, is to avoid loops, because in your case, say product updated – you calculate new MF values and change metafields => product updated is triggered again.
However, what you can do is to schedule a Flow to run, say every 10 minutes and get products updated during these last 10 minutes. Then do whatever to them keeping in mind to avoid loops.
Since the price is changed on the variant, you can get variants changed, but update MF on product, this way variant is not updated again => no looping.