Skip to content

Modify Basket

Once items are in the basket, these mutations cover the rest of the lifecycle: changing quantities, swapping variants, removing items, picking and removing select-your-sample gifts, and clearing the basket. All return the full Basket so the client can render the new state without a follow-up query.

All mutations take a basketId and the same SessionSettings (currency, shippingDestination) as the rest of the basket API. Passing null for basketId falls back to the logged-in customer’s saved basket or creates a new one. The returned basket id may differ from the one passed in if the basket moved, merged or didn’t exist.

Updating the quantity of an item

mutation UpdateProductQuantity {
updateProductQuantityInBasket(
basketId: "2298e807-50ee-4120-abfa-3c0f0ef78fca:1611587680727"
itemId: "item_abc123"
quantity: 3
settings: { currency: GBP, shippingDestination: GB }
) {
id
items {
id
quantity
totalChargePrice {
amount
currency
displayValue
}
}
chargePrice {
amount
currency
displayValue
}
}
}

Removing an item

mutation RemoveProductFromBasket {
removeProductFromBasket(
basketId: "2298e807-50ee-4120-abfa-3c0f0ef78fca:1611587680727"
itemId: "item_abc123"
settings: { currency: GBP, shippingDestination: GB }
) {
id
totalQuantity
items {
id
product {
title
}
quantity
}
}
}

Swapping to a similar variant

amendProductInBasket swaps a basket item to a different variant of the same product — typically used when the customer changes their mind about a size, colour or flavour from the basket page. Use BasketItem.similarVariations to populate the picker. Pass quantity to change it at the same time; omit to keep the current quantity.

mutation AmendProductInBasket {
amendProductInBasket(
basketId: "2298e807-50ee-4120-abfa-3c0f0ef78fca:1611587680727"
itemId: "item_abc123"
newSku: 12345678
quantity: 2
settings: { currency: GBP, shippingDestination: GB }
) {
id
items {
id
product {
sku
title
}
quantity
}
}
}

Removing a discount code

For removing a code that’s already been applied with applyCodeToBasket. Automatically-applied (non-removeable) offers cannot be cleared this way — check AppliedOffer.removeable before exposing the remove action.

mutation RemoveCodeFromBasket {
removeCodeFromBasket(
basketId: "2298e807-50ee-4120-abfa-3c0f0ef78fca:1611587680727"
settings: { currency: GBP, shippingDestination: GB }
) {
id
code {
value
}
appliedOffers {
message {
value
}
removeable
}
}
}

Select Your Sample — adding and removing the chosen gift

Once the basket qualifies for a SelectYourSample tier, the customer picks one of the tier’s products. Pass the selectYourSampleId, the chosen tierId and the SKU of the variant they selected.

mutation AddSelectYourSampleProduct {
addSelectYourSampleProductToBasket(
basketId: "2298e807-50ee-4120-abfa-3c0f0ef78fca:1611587680727"
selectYourSampleId: "sys_42"
tierId: "tier_1"
sku: 99999
settings: { currency: GBP, shippingDestination: GB }
) {
id
selectYourSample {
id
selectedSysProducts {
productVariants {
sku
title
}
}
maxSelectedProducts
}
}
}
mutation RemoveSelectYourSampleProduct {
removeSelectYourSampleProductFromBasket(
basketId: "2298e807-50ee-4120-abfa-3c0f0ef78fca:1611587680727"
selectYourSampleId: "sys_42"
tierId: "tier_1"
sku: 99999
settings: { currency: GBP, shippingDestination: GB }
) {
id
selectYourSample {
id
selectedSysProducts {
productVariants {
sku
}
}
}
}
}

Emptying the basket

Clears every item.

mutation EmptyBasket {
emptyBasket(
basketId: "2298e807-50ee-4120-abfa-3c0f0ef78fca:1611587680727"
settings: { currency: GBP, shippingDestination: GB }
) {
id
totalQuantity
items {
id
}
}
}