How to track variants metafield updates using webhooks or something?

mmarienko
Shopify Partner
23 0 11

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
Reply 1 (1)

keligijus
Shopify Partner
1 0 0

+1 having the same issue.

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