Edit in GitHubLog an issue

createGuestCart mutation

The createGuestCart mutation creates an empty shopping cart for a guest shopper. You can allow the system to generate a cart ID, or assign a specific ID.

Syntax

Copied to your clipboard
mutation {
createGuestCart(input: ApplyCouponToCartInput) {
CreateGuestCartOutput
}
}

Reference

The createGuestCart reference provides detailed information about the types and fields defined in this mutation.

Example usage

Create a cart with a randomly-generated cart ID

Request:

Copied to your clipboard
mutation {
createGuestCart {
cart {
id
}
}
}

Response:

The response is the newly created cart.

Copied to your clipboard
{
"data": {
"createGuestCart": {
"cart": {
"id": "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C"
}
}
}
}

Create a guest cart with an assigned cart ID

You can also create a guest cart with a specified cart_id.

Request:

Copied to your clipboard
mutation {
createGuestCart (input: {cart_uid: "x2345678901234567890123456789012"}) {
cart {
id
}
}
}

Response:

The mutation returns a cart using the same cart_id.

Copied to your clipboard
{
"data": {
"createGuestCart": {
"cart": {
"id": "x2345678901234567890123456789012"
}
}
}
}

Errors

ErrorDescription
Cart with ID "XXX" already exists.
The specified cart ID was previously used to create a cart.
Cart ID length should to be 32 symbols.
The cart ID is not the required length.
Use 'Query.customerCart' for logged in customer.
A logged in customer is trying to create a guest customer cart.
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.