Skip to main content

Cart metafields are accessible in Shopify Functions and Checkout UI extensions

You can now read cart metafields in the GraphQL input query for Shopify Functions. Checkout UI extensions can also read and write cart metafields for abandoned carts, order edits, and draft orders, in addition to previously supported resources. Notably, cart metafields are carried over to abandoned carts for later use.

For security, use a reserved namespace to ensure only your app can access specific cart metafields.

Note: If you modify cart metafields using the cartMetafieldsSet or cartMetafieldDelete mutations, then the changes won't be available to Shopify Functions until the buyer goes to checkout or performs another cart action that triggers the function.

Example: Read a cart metafield in a function input query

query RunInput {
  cart {
    myCartMetafield: metafield(namespace: "myNamespace", key: "myCartMetafield") {
      value
    }
  }
}
Was this section helpful?