B2B for Adobe Commerce only. Learn more.

clearCustomerCart mutation

The clearCustomerCart mutation clears the customer’s cart.

This mutation requires a valid customer authentication token.

Use the storeConfig query with the is_requisition_list_active attribute to determine whether requisition lists are enabled.

Syntax

1
2
3
4
5
6
7
mutation {
  clearCustomerCart(
    cartUid: String!
  ) {
    ClearCustomerCartOutput
  }
}

Example usage

The following example clears the customer’s cart.

Request:

1
2
3
4
5
6
7
mutation {
  clearCustomerCart(
      cartUid: "8k0Q4MpH2IGahWrTRtqM61YV2MtLPApz"
    ) {
        status
    }
}

Response:

1
2
3
4
5
6
7
{
  "data": {
    "clearCustomerCart": {
        "status": "true"
    }
  }
}

Input attributes

The clearCustomerCart mutation requires the following input.

Attribute Data Type Description
cartUid String! Indicates whether cart was cleared

Output attributes

The clearCustomerCart object returns the status and cart object.

Attribute Data Type Description
cart Cart The cart after clearing items
status Boolean! The requisition list after the items were added

Cart object

The Cart object can contain the following attributes.

Attribute Data Type Description
applied_coupon AppliedCoupon Deprecated. Use applied_coupons instead
applied_coupons [AppliedCoupon] An array of AppliedCoupon objects. Each object contains the code text attribute, which specifies the coupon code
applied_gift_cards [AppliedGiftCard] An array of AppliedGiftCard objects. An AppliedGiftCard object contains the code text attribute, which specifies the gift card code. applied_gift_cards is a Commerce-only attribute, defined in the GiftCardAccountGraphQl module
applied_reward_points RewardPointsAmount The amount of reward points applied to the cart
applied_store_credit AppliedStoreCredit Contains store credit information applied to the cart. applied_store_credit is a Commerce-only attribute, defined in the CustomerBalanceGraphQl module
available_gift_wrappings [GiftWrapping]! The list of available gift wrapping options for the cart
available_payment_methods [AvailablePaymentMethod] Available payment methods
billing_address BillingCartAddress Contains the billing address specified in the customer’s cart
email String The customer’s email address
gift_message GiftMessage A gift message added to the cart
gift_receipt_included Boolean! Indicates if the customer requested a gift receipt for the cart
gift_wrapping GiftWrapping The selected gift wrapping for the cart
id ID! The unique ID of the cart
is_virtual Boolean! Indicates whether the cart contains only virtual products
items [CartItemInterface] Contains the items in the customer’s cart
prices CartPrices Contains subtotals and totals
printed_card_included Boolean! Indicates if the customer requested a printed card for the cart
selected_payment_method SelectedPaymentMethod Selected payment method
shipping_addresses [ShippingCartAddress]! Contains one or more shipping addresses
total_quantity Float! Total Quantity of products in the cart