cartRemoveItem
Overview
Call removeCartItem with the ID of the line item to delete. The response mirrors the cart structure so you can refresh totals, coupons, and UI state immediately.
- Type: GraphQL Mutation
- Endpoint: https://appssubdomain.com
- Authentication:
Authorization: Bearer <TOKEN>(session/account)
Mutation
mutation RemoveCartItem($data: RemoveCartItemInput!) {
removeCartItem(data: $data) {
data {
_id
app
account {
_id
verified
blocked
orderCount
lastSeen
createdAt
updatedAt
}
coupon
kind
couponApplied
couponDiscount
items {
_id
productId
variantId
productData { title slug app image { _id fileUrl } price }
variantData {
price
compareAtPrice
options {
_id
option { _id name type product }
label
sortOrder
}
}
quantity
price
compareAtPrice
totalPrice
totalCompareAtPrice
totalSavings
}
deviceId
sessionId
status
totalQuantity
totalPrice
totalCompareAtPrice
totalSavings
isFastOrder
createdAt
updatedAt
url
encryptionKey
}
success
message
}
}
Variables
{
"data": {
"itemId": "<CART_ITEM_ID>"
}
}
Examples
- cURL
- JavaScript (fetch)
curl -X POST \
https://appssubdomain.com\
-H "Content-Type": "application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{
"query": "mutation RemoveCartItem($data: RemoveCartItemInput!) { removeCartItem(data: $data) { success message data { _id totalPrice items { _id quantity } } } }",
"variables": {
"data": {
"itemId": "<CART_ITEM_ID>"
}
}
}
EOF
const res = await fetch('https://appssubdomain.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token,
},
body: JSON.stringify({
query: `
mutation RemoveCartItem($data: RemoveCartItemInput!) {
removeCartItem(data: $data) {
success
message
data { _id totalPrice totalQuantity }
}
}
`,
variables: {
data: { itemId: '<CART_ITEM_ID>' },
},
}),
});
const json = await res.json();
Notes
- Use the returned cart snapshot to update UI and detect whether coupon totals changed after removal.
- Validate
itemIdbelongs to the current session/account before calling, otherwise expect an error inmessage.