I'm currently trying to use the cartMetafieldsSet query in the Storefront API to add user generated information on to the order.
The below query seems to successfully add the metafield onto the cart object, however after proceeding to the checkout and paying, the metafield on the order is blank.
I have a couple of questions
- Does anyone know why the metafield isn't showing on my order?
- Is there a difference between
cartMetafieldsSeton the Storefront API and themetafieldsSeton the admin API?
// GraphQL Query
mutation cartMetafieldsSet($metafields: [CartMetafieldsSetInput!]!) {
cartMetafieldsSet(metafields: $metafields) {
metafields {
# Metafield fields
createdAt
description
value
}
}
}
// Variables
{
"metafields": [
{
"key": "custom.test",
"ownerId": "CART_ID",
"type": "multi_line_text_field",
"value": "This is a test value"
}
]
}
Here is how I defined my metafield in Shopify
Thanks for your help!

You're mixing two concepts. A cart is not an order. A cart metafield can be set with Storefront API sure. You do that to affect checkout. In checkout you get a cart, and you look at the metafield, and perhaps that helps in checkout.
But once Shopify has converted a checkout to an order, what makes you think you are going to find a metafield set on the cart? If you want to capture information in a cart, use cart attributes or a note. Those show up in order fine.