Cover Image for Understanding Shopify Webhooks: Custom Metafields Aren't Included in Order/Create Payloads

Understanding Shopify Webhooks: Custom Metafields Aren't Included in Order/Create Payloads

TLDR;

Product custom metafields are NOT included in the JSON payload of the order/create webhook.

Details

Not too long ago I was integrating an external ERP to a Shopify store. The ERP would subscribe to the order/create webhook so that it would be notified any time a new order was created in Shopify. The product model in Shopify had been customized with custom metafields as is common for Shopify. There was a requirement that the ERP must receive one of the custom product attributes so that it could fulfill the order correctly.

I had assumed that the custom product metafields would be included in the JSON payload of the order/create webhook. I was wrong. The custom metafields were not included in the JSON payload.

Documentation

Topic: orders/create

Specifically I am referring to the line_items section of the webhook payload. If you have metafields configured for your product or variant you must not expected to find them in the line_items section of the webhook payload.

Conclusion

The line_items section of the webhook payload is not populated with the custom metafields. In order to get the custom metafield values you must make an additional request to the Shopify API with the product or variant ID that was received in the webhook. Using the product or variant ID you can make a request to the Shopify API to retrieve the custom metafield values.