Cart
Session-based cart with items, coupons, and totals.
TS
// Add item with variant + add-ons (requires a quote), update quantity, apply coupon
const quote = await client.catalogue.fetchQuote({
product_id: 'prod_xxxxx',
variant_id: 'var_large',
add_on_option_ids: ['addon_oat_milk'],
})
if (!quote.ok) throw quote.error
const add = await client.cart.addItem({
item_id: 'prod_xxxxx',
quantity: 2,
variant_id: 'var_large',
quote_id: quote.value.quote_id,
add_on_options: ['addon_oat_milk'],
special_instructions: 'No sugar',
})
if (!add.ok) throw add.error
await client.cart.updateQuantity(add.value.items[0].id, 3)
await client.cart.applyCoupon('SUMMER20')
const cart = await client.cart.get()
if (cart.ok) console.log(cart.value.pricing.total_price)Cart is session-based, tied to the browser session cookie. No authentication required.
get
Returns the enriched cart with items, pricing, and applied discounts.
TS
const cart = await client.cart.get() // Result<UICart>
if (cart.ok) {
console.log(cart.value.id)
console.log(cart.value.items)
console.log(cart.value.pricing.total_price)
}addItem
| Field | Type | Required | Description |
|---|---|---|---|
item_id | string | Yes | Product ID |
quantity | number | No | Defaults to 1 |
variant_id | string | No | Selected variant |
quote_id | string | No | From catalogue.fetchQuote() |
add_on_options | string[] | No | Selected add-on option IDs |
special_instructions | string | No | Custom notes for the item |
bundle_selections | BundleSelection[] | No | Bundle component picks |
composite_selections | CompositeSelection[] | No | Composite component picks |
scheduled_start | string | No | ISO datetime for scheduling |
scheduled_end | string | No | ISO datetime for scheduling |
staff_id | string | No | Preferred staff member |
For items with variants or add-ons, get a quote first via catalogue.fetchQuote(), then pass the quote_id to addItem.
updateQuantity / removeItem / clear
TS
await client.cart.updateQuantity('cart_item_xxxxx', 3) // Result<Cart>
await client.cart.removeItem('cart_item_xxxxx') // Result<Cart>
await client.cart.clear() // Result<Cart>getCount / getTotal
TS
const count = await client.cart.getCount() // Result<number>
const total = await client.cart.getTotal() // Result<string> (formatted amount)Coupons
TS
const apply = await client.cart.applyCoupon('SUMMER20')
if (!apply.ok) {
console.error(apply.error.code, apply.error.message)
}
await client.cart.removeCoupon()All Methods
| Method | Returns |
|---|---|
get() | Result<UICart> |
addItem(input) | Result<Cart> |
updateQuantity(itemId, qty) | Result<Cart> |
removeItem(itemId) | Result<Cart> |
clear() | Result<Cart> |
getCount() | Result<number> |
getTotal() | Result<string> |
applyCoupon(code) | Result<Cart> |
removeCoupon() | Result<Cart> |