Remove an item from the cart
Delete a line item from the cart by its item ID.
Mutation
mutation RemoveCartItem($cartId: String!, $itemId: String!) {
cartDeleteItem(
id: $cartId
input: { itemId: $itemId }
) {
items {
itemId
productId
quantity
}
total {
subTotal
totalGross
totalNet
}
}
}
Variables
{
"cartId": "019c77b7-565f-7ea0-8660-42bc63a7f728",
"itemId": "019c77b7-72a0-75fe-8a20-b98927d76652"
}
Response
{
"data": {
"cartDeleteItem": {
"items": [],
"total": {
"subTotal": 0,
"totalGross": 355,
"totalNet": 429.55
}
}
}
}
How it works
Note that itemId goes inside the input object here, unlike cartUpdateItem where it's a top-level argument. When the cart is empty, totalGross may still be non-zero due to base shipping costs. The response returns the updated cart so you can refresh the UI immediately.