Use this mutation to attach arbitrary key-value pairs to a cart. Attributes can be used to store additional metadata about the cart, such as custom order notes, referral sources, or customer preferences.
Arguments
The unique identifier of the cart to update.
A list of key-value pairs to set on the cart. Each attribute has a key and value field, both limited to 500 characters.
Returns
SetCartAttributesResult.userErrors
List of errors that occurred while setting cart attributes.
Example - request
{
"id": "{{cartId}}",
"attributes": [
{
"key": "gift_message",
"value": "Happy Birthday!"
},
{
"key": "referral_source",
"value": "instagram"
}
]
}
mutation ($id: ID!, $attributes: [AttributeInput!]!) {
setCartAttributes(id: $id, attributes: $attributes) {
userErrors {
code
message
}
}
}
Example - response
{
"data": {
"setCartAttributes": {
"userErrors": []
}
}
}