I have set metafield in a draft order, but it does not appear in the cart > metafield graphQL input (it shows as null), is this intended? ( Cart Transform Function API )
query Input {
cart {
attribute {
key
value
}
metafield(key:"promotion_id"){
value
}
}
}
I would like to avoid cart attribute (draft order “additional details”) as this can be modified / seen by merchants.
Hey @soulchild! I took a look into this for you internally and found it is expected behavior that a metafield set on a draft order isn’t available through cart.metafield in a Cart Transform input.
Your query shape is valid, so this isn’t a syntax or field-selection problem. Cart metafields are accessible in Shopify Functions and Checkout UI extensions added cart.metafield to read cart-owned metafields, not to surface metafields from other resources like draft orders.
So in other words the cart.metafield field reads metafields owned by the cart resource itself, and draft orders and carts are separate resources, so a draft order metafield doesn’t flow through there regardless of namespace.
I understand the goal of avoiding cart attributes since those are visible and editable by merchants. There isn’t currently a supported way to pass private, draft-order-owned data into a Cart Transform function through cart.metafield so I’ve passed this as feedback to the owning team. I can’t say if and when this might be implemented but I can say that the right people are aware - thanks for pointing this out!