Anchor to section titled 'undefined'

cartMetafieldsSet
mutation

Sets cart metafield values. Cart metafield values will be set regardless if they were previously created or not.

Allows a maximum of 25 cart metafields to be set at a time.


The list of Cart metafield values to set. Maximum of 25.

The input must not contain more than 250 values.


Was this section helpful?

The list of cart metafields that were set.

The list of errors that occurred from executing the mutation.


Was this section helpful?
Hide code
Mutation reference
Copy
mutation cartMetafieldsSet($metafields: [CartMetafieldsSetInput!]!) {
  cartMetafieldsSet(metafields: $metafields) {
    metafields {
      # Metafield fields
    }
    userErrors {
      field
      message
    }
  }
}
Hide code
Input
Copy
{
  "metafields": [
    {
      "key": "<your-key>",
      "ownerId": "gid://shopify/<objectName>/10079785100",
      "type": "<your-type>",
      "value": "<your-value>"
    }
  ]
}
input CartMetafieldsSetInput {
  key: String!
  ownerId: ID!
  type: String!
  value: String!
}