Update Cart Items
UpdateCartItems Mutation
This mutation updates the quantity of an existing simple item in the customer cart, or removes it entirely when the quantity is set to 0. It uses the updateSimpleItem cart action.
Use Cases​
- Quantity changes: Let customers increase or decrease item quantities from the landing page mini-cart.
- Remove from cart: Allow removing a line item by setting its quantity to
0. - Inline cart editing: Keep customers on the landing page while they refine their cart.
Headers​
Use the same sessionid header as in the other cart SampleAPIs:
{
"sessionid": "Session_3f6a0f1d-9c4a-4f3e-8f4b-1a2b3c4d5e6f"
}
Input Parameters​
$storeId: ID!– The store where the cart lives.$item: SimpleItemInput!variantId: ID!– The variant in the cart you want to modify.quantity: Int!– New quantity:> 0→ update the quantity.0→ remove the item from the cart.
Note:
SimpleItemInputalso allowsitemId, but for this SampleAPI you can rely onvariantId + quantityto update/remove.
Behavior​
- If the variant is already in the cart:
- Calling
UpdateCartItemswithquantity > 0adjusts the quantity. - Calling
UpdateCartItemswithquantity = 0removes that line item.
- Calling
- If the variant is not in the cart, behavior depends on backend rules (typically you should add via
AddToCartfirst).
Response Structure​
Returns an updated Cart object:
id,sessionId,status,cartStep– Cart metadata.items– Updated list of items (for simple items):idquantityprice/totalPrice(Money)variant(basic product info)
receipt– Updated monetary breakdown:subtotal,discount,shipping,tax,automaticDiscount,total.
Example Variables​
Update quantity to 2:
{
"storeId": "Store_cm84j35iy02m001i89iiu2cts",
"item": {
"variantId": "ProductVariant_cmi3ooen020wf01yh5n7ef0ht",
"quantity": 2
}
}
Remove the item completely (set quantity to 0):
{
"storeId": "Store_cm84j35iy02m001i89iiu2cts",
"item": {
"variantId": "ProductVariant_cmi3ooen020wf01yh5n7ef0ht",
"quantity": 0
}
}
Implementation Notes​
- Use
UpdateCartItemsfrom your landing page mini-cart UI to handle both quantity changes and remove actions. - Always send the same
sessionidheader value you used forAddToCart/ReplaceCartItemsso all operations target the same cart. - After calling this mutation, you can refresh the cart summary via
GetCartor rely on the returned cart payload.
GraphQL Endpoint​
https://graphql.wuilt.com
Operation: UpdateCartItems​
Try It Out​
Query​
Query Variables
1
2
3
4
5
6
7
Note: Make sure to change the storeId with your store ID. For guidance on how to get your store ID, reference the Store ID guide.
Authentication​
To use this query, you will need an API key. Click the "API Key" button in the navigation bar to enter your credentials.