How to track variants metafield updates using webhooks or something?

How to track variants metafield updates using webhooks or something?

mmarienko
Shopify Partner
23 0 14

I need to track an event when a merchant was changed variant metafield to check the value and push something to another host.

export default {
  PRODUCTS_UPDATE: {
    deliveryMethod: DeliveryMethod.Http,
    callbackUrl: "/api/webhooks",
    includeFields: [
      "variants"
    ],
    metafieldNamespaces: [
      "custom"
    ],
    callback: async (topic, shop, body, webhookId) => {
      console.log('--- Product update ---');
      const payload = JSON.parse(body);
      console.log(payload.variants);
      console.log('--- /Product update ---');
    },
  },
};


I'm trying to create the webhook for it. But the PRODUCTS_UPDATE topic works for product internal changes (title/description/options/product metafields and etc.), and even for variant title/description/price/etc changes but not for the variants metafields. Only for the first their call, I suppose when the metafield is created.

Does someone know how to expand the webhook to track variant metafield or you know another way?
 

Regards, Max Marienko - Shopify Expert
Replies 2 (2)

keligijus
Shopify Partner
5 0 2

+1 having the same issue.

`products/update` webhook is not triggered by variant metafield updates, but it is by product metafield updates

pepsimax2k
Shopify Partner
15 0 0

Same issue here. inventory_items/update webhook doesn't do it either. Is there any webhook that triggers on variant metafield update?