setCartItemQuantity
Sets how many tickets of one ticket type a cart contains, creating the cart if needed.
The quantity is the desired absolute total for that item, not a delta. If the cart already holds 2 and you pass 3, one is added; pass 1 and one is removed; pass 0 and all of them are removed. Setting the quantity a cart already has is a no-op.
Pass null for cartId to start a new cart. The shop identified by shopSlug (see Shop.slug) determines
which items can be added and which prices apply, and the new cart's ID is returned as Cart.id on
SetCartItemQuantityResult.cart — keep it and pass it to every follow-up call. Passing the ID of a cart
that does not exist or has already expired fails with an error.
The itemId is a ShopItem.id from ShopEvent.items. This mutation is the primary way to buy ticket
types that are not placed on a seatmap. For a specific seat use addSeatToCart, and for a
general admission area of a seatmap use setCartVolumeQuantities.
Supply passwords when the ticket type is hidden behind one. Without a matching password the ticket type is not visible to the call and it fails with an error.
Ticket types may also restrict which totals can be bought at once. ShopItem.quantities and
CartItem.availableQuantities list the values you can switch to; passing a different quantity leaves the
cart as it was and is not reported as an error.
Always check SetCartItemQuantityResult.error before using the result. It is non-null when the ticket
type could not be added because it is sold out or not currently on sale, in which case the cart was not
changed and requesting SetCartItemQuantityResult.cart in the same response yields a field error
instead of a cart. The value is an error code, currently always NOT_ENOUGH_AVAILABLE, meant to be
mapped to a message in your own frontend. Exceeding the number of tickets a single customer may buy for
an event fails with an error rather than through this field.
mutation AddToCart($shopSlug: ID!, $itemId: ID!, $quantity: Int!, $cartId: ID) { setCartItemQuantity(shopSlug: $shopSlug, itemId: $itemId, quantity: $quantity, cartId: $cartId) { cart { id grandTotal { amount } items { name quantity } } error } }mutation AddToCart($shopSlug: ID!, $itemId: ID!, $quantity: Int!, $cartId: ID) { setCartItemQuantity(shopSlug: $shopSlug, itemId: $itemId, quantity: $quantity, cartId: $cartId) { cart { id grandTotal { amount } items { name quantity } } error } }
Arguments
| Argument | Description | Type |
|---|---|---|
| cartId | ID | |
| shopSlug | ID! | |
| itemId | ID! | |
| quantity | Int! | |
| passwords | If an item is password protected, you need to specify the required password here. | [ String! ] |
Type
This field resolves to SetCartItemQuantityResult!.