data-src=../../../../includes/paas-only.md
data-src=../../../../includes/commerce-only.md

clearCart mutation

The clearCart mutation removes all items from the specified cart.

Syntax

mutation {
  clearCart(input: ClearCartInput) {
      ClearCartOutput
  }
}

Reference

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

Example usage

Request:

mutation {
    clearCart(input: {uid: "B79Qefk7pUaxahYtO8WjOtr5UyEyjaYV"}) {
        cart {
            id
            itemsV2 {
                items {
                    uid
                }
            }
        }
        errors {
            message
        }
    }
}

Response:

The response is the cart with no items.

{
  "data": {
    "clearCart": {
      "cart": {
        "id": "B79Qefk7pUaxahYtO8WjOtr5UyEyjaYV",
        "itemsV2": {
          "items": []
        }
      },
      "errors": null
    }
  }
}