Transfer Cart Metafield to Order

Topic summary

Main issue: How to carry a cart metafield set via Hydrogen’s cart.setMetafields into the resulting order.

Context and terms:

  • Metafields: custom, namespaced fields (e.g., custom.gift) defined on resources like orders/draft orders.
  • Cart attributes: simple key–value fields that often appear on the final order.

Observed behavior:

  • When using cart.setMetafields (per Shopify Hydrogen docs), the cart metafield is created successfully on the cart.
  • Cart attributes set on the cart appear on the final order as expected.
  • Creating a matching metafield (e.g., custom.gift) on the order and draft order definitions does not result in that value being populated on the order during checkout.

Open question:

  • Is there a supported way to transfer cart metafields to order metafields, or additional steps required to map them?

Status: Unresolved; seeking guidance/confirmation.

Summarized with AI on December 30. AI used: gpt-5.

When utilising “cart.setMetafields” how can this metafield be transferred to the order?

Following this example:

https://shopify.dev/docs/custom-storefronts/hydrogen/cart/metafields

If I set “Cart Attributes” I can see these straightaway on the final order. But if I create a matching metafield such as custom.gift on the order & draft order definitions this does not get set using cart.setMetafield.

As I understand it’s setting the cart metafield successfully but this doesn’t get transferred to the order?

2 Likes