Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

metafield for products not working on the order/paid webhook

metafield for products not working on the order/paid webhook

Pjijin
Shopify Partner
2 0 0

I have added metafield on the products and created a webhook for the order/paid using the graphql.

```
mutation{
webhookSubscriptionCreate(topic: ORDERS_PAID, webhookSubscription:{
callbackUrl: "https://9426-103-203-73-98.ngrok-free.app/api/webhook/mint_nft",
format: JSON,
includeFields: [
"metafield"
],
metafieldNamespaces:[
"contract_id",
"campaign_id"
]
}){
webhookSubscription{
id
createdAt
}
}
}
```
Using the webhook, When i console.log it is showing metafields on the customers. I am looking for the metafields on the products.


```
line_items: [
{
id: 12583870496883,
admin_graphql_api_id: 'gid://shopify/LineItem/12583870496883',
fulfillable_quantity: 1,
fulfillment_service: 'manual',
fulfillment_status: null,
gift_card: false,
grams: 0,
name: 'bc test',
price: '0.00',
price_set: [Object],
product_exists: true,
product_id: 7168562462835,
properties: [],
quantity: 1,
requires_shipping: false,
sku: '',
taxable: false,
title: 'bc test',
total_discount: '0.00',
total_discount_set: [Object],
variant_id: 40872835383411,
variant_inventory_management: null,
variant_title: null,
vendor: 'devztest',
tax_lines: [],
duties: [],
discount_allocations: []
}
```

 

 

 

Reply 1 (1)

Liam
Community Manager
3108 344 911

Hi Pjijin,

 

The order related webhooks won't have product metafields in their payloads - only product related webhooks will (eg: the product update webhook will allow you to access that products metafields). You may need to make a separate call to the Admin API to get the metafields. What is the specific use case you're looking to achieve here?

 

Hope this helps,

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog