Ad

Limit Variant Fields For Shopify Product/update Webhook

- 1 answer

How would I limit the fields that webhooks send for Shopify's product/update webhook?

I can send fields like below, when I create the webhook, but how would I restrict fields in the list of variants?

new_webhook = shopify.Webhook()
new_webhook.topic = 'product/update'
new_webhook.fields = ["id","title","variants","updated_at"]
new_webhook.save()

Sample Response (with the above fields) is below. All I care about from the variant objects is 'id', 'title', 'sku', and 'updated_at' (i.e. I don't need all that other data):

{
  "id": 327475578523353102,
  "title": "Example T-Shirt",
  "updated_at": null,
  "variants": [
    {
      "id": 1234567,
      "product_id": 327475578523353102,
      "title": "",
      "price": "19.99",
      "sku": "example-shirt-s",
      "position": 0,
      "grams": 200,
      "inventory_policy": "deny",
      "compare_at_price": "24.99",
      "fulfillment_service": "manual",
      "inventory_management": null,
      "option1": "Small",
      "option2": null,
      "option3": null,
      "created_at": null,
      "updated_at": null,
      "taxable": true,
      "barcode": null,
      "image_id": null,
      "inventory_quantity": 75,
      "weight": 0.44,
      "weight_unit": "lb",
      "old_inventory_quantity": 75,
      "requires_shipping": true
    },
    {
      "id": 1234568,
      "product_id": 327475578523353102,
      "title": "",
      "price": "19.99",
      "sku": "example-shirt-m",
      "position": 0,
      "grams": 200,
      "inventory_policy": "deny",
      "compare_at_price": "24.99",
      "fulfillment_service": "manual",
      "inventory_management": "shopify",
      "option1": "Medium",
      "option2": null,
      "option3": null,
      "created_at": null,
      "updated_at": null,
      "taxable": true,
      "barcode": null,
      "image_id": null,
      "inventory_quantity": 50,
      "weight": 0.44,
      "weight_unit": "lb",
      "old_inventory_quantity": 50,
      "requires_shipping": true
    }
  ]
}
Ad

Answer

You cannot restrict the variant fields returned when you ask for product data.

Ad
source: stackoverflow.com
Ad