Edit in GitHubLog an issue

createEmptyCart mutation

The createEmptyCart mutation creates an empty shopping cart for a guest or logged in customer. You can allow the system to generate a cart ID, or assign a specific ID.

If you are creating a cart for a logged in customer, you must include the customer's authorization token in the header of the request.

Syntax

Copied to your clipboard
mutation {
createEmptyCart {
String
}
}

Reference

The createEmptyCart 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 {
createEmptyCart
}

Response:

The response is the cart ID, which is sometimes called the quote ID. The remaining examples in this topic will use this cart ID.

Copied to your clipboard
{
"data": {
"createEmptyCart": "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C"
}
}

Create an empty cart with an assigned cart ID

You can also create an empty cart with a specified cart_id.

Request:

Copied to your clipboard
mutation {
createEmptyCart(
input: {
cart_id: "x2345678901234567890123456789012"
}
)
}

Response:

The mutation returns the same cart_id.

Copied to your clipboard
{
"data": {
"createEmptyCart": "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.
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.