cimplify

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

FieldTypeRequiredDescription
item_idstringYesProduct ID
quantitynumberNoDefaults to 1
variant_idstringNoSelected variant
quote_idstringNoFrom catalogue.fetchQuote()
add_on_optionsstring[]NoSelected add-on option IDs
special_instructionsstringNoCustom notes for the item
bundle_selectionsBundleSelection[]NoBundle component picks
composite_selectionsCompositeSelection[]NoComposite component picks
scheduled_startstringNoISO datetime for scheduling
scheduled_endstringNoISO datetime for scheduling
staff_idstringNoPreferred 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

MethodReturns
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>