removeItemFromCart mutation
The removeItemFromCart
mutation deletes the entire quantity of a specified item from the cart. If you remove all items from the cart, the cart continues to exist.
Syntax
mutation: {removeItemFromCart(input: RemoveItemFromCartInput): {RemoveItemFromCartOutput}}
Reference
The removeItemFromCart
reference provides detailed information about the types and fields defined in this mutation.
Example usage
The following example removes cart item 14 from the cart.
Request:
Copied to your clipboardmutation {removeItemFromCart(input: {cart_id: "IeTUiU0oCXjm0uRqGCOuhQ2AuQatogjG",cart_item_id: 14}){cart {itemsV2 {items {idproduct {name}quantity}total_countpage_info {page_sizecurrent_pagetotal_pages}}prices {grand_total{valuecurrency}}}}}
Response:
Copied to your clipboard{"data": {"removeItemFromCart": {"cart": {"itemsV2": {"items": [{"uid": "NDA=","product": {"name": "Strive Shoulder Pack"},"quantity": 3}],"total_count": 1,"page_info": {"page_size": 20,"current_page": 1,"total_pages": 1}},"prices": {"grand_total": {"value": 96,"currency": "USD"}}}}}}
Errors
Error | Description |
---|---|
Cart doesn't contain the ZZZ item. | The item ID specified in the cart_item_id argument does not exist in the requested shopping cart. |
Could not find a cart with ID "XXX" | The specified cart_id value does not exist in the quote_id_mask table. |
Required parameter "cart_id" is missing. | The value specified in the cart_id argument is empty. |
Required parameter "cart_item_id" is missing. | The value specified in the cart_item_id argument is equal to zero. |
The current user cannot perform operations on cart "XXX" | An unauthorized user (guest) tried to remove a product from the shopping cart of authorized user (customer), or a customer tried to remove a product from the shopping cart of another customer. |