Edit in GitHubLog an issue
Thanks to Atwix for contributing this topic!

assignCustomerToGuestCart mutation

The assignCustomerToGuestCart mutation merges a logged-in customer's shopping cart into the specified guest cart. The mutation inactivates the customer's shopping cart and moves the products to the guest cart. The guest cart is then assigned to the customer.

This mutation requires a valid customer authentication token.

Syntax

Copied to your clipboard
mutation {
assignCustomerToGuestCart(
cart_id: String!
) {
Cart!
}
}

Reference

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

Example usage

In the following example, the customer and guest carts each contain one item. The mutation merges the customer's cart to the guest cart. As a result, the guest cart contains two items.

Request:

Copied to your clipboard
mutation {
assignCustomerToGuestCart(
cart_id: "MDYKgqIdWMKr7VD1zlYwxrB7kuX8lR5s"
) {
itemsV2 {
items {
quantity
product {
sku
}
}
total_count
page_info {
page_size
current_page
total_pages
}
}
}
}

Response:

Copied to your clipboard
{
"data": {
"assignCustomerToGuestCart": {
"itemsV2": {
"items": [
{
"quantity": 1,
"product": {
"sku": "customer_item"
}
},
{
"quantity": 1,
"product": {
"sku": "guest_item"
}
}
],
"total_count": 1,
"page_info": {
"page_size": 20,
"current_page": 1,
"total_pages": 1
}
}
}
}
}

Errors

ErrorDescription
The current customer isn't authorized.
The current customer is not currently logged in.
Unable to assign the customer to the guest cart
The current customer can't be assigned to the provided guest cart.
The cart isn't active
The cart with the specified cart ID is unavailable, because the items have been purchased and the cart ID becomes inactive.
Could not find a cart with ID "XXX"
The specified cart_id value does not exist in the quote_id_mask table.
The current user cannot perform operations on cart "XXX"
Tried to assign the customer to the customer's cart.
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.