Skip to main content
This guide covers the full cart lifecycle — from creating a session to adding items with modifiers, updating quantities, applying discounts, and clearing the cart.

Cart lifecycle overview

1

Start an ordering session

Creates a cart and returns a cartId you use for all subsequent operations.
2

Add items

Add products with quantities and modifier selections.
3

Update items

Change quantities or remove individual items.
4

Apply discounts

Optionally apply a promo code.
5

Proceed to checkout

Set customer details, fulfillment method, and payment.

Start an ordering session

Persist the cartId in local storage or a cookie so returning users resume their cart.

Add an item

Add an item with modifiers

Modifiers represent customizations (e.g., size, toppings, extras). Pass them in the selections array.

Item unavailable actions

When an item becomes unavailable after being added (e.g., sold out), Crave handles it based on the itemUnavailableAction field:
ActionBehavior
remove_itemRemove the specific item from the cart
cancel_entire_orderCancel the whole order if any item is unavailable

Get the cart

Update item quantity

Set quantity to 0 to remove the item.

Apply a discount

Remove a discount

Show upsell suggestions based on the current cart contents.

Delete the cart

Cart data model

The StorefrontCart type includes these key fields:
FieldTypeDescription
idstringUnique cart ID
itemsCartItem[]Line items with quantity, modifiers, price
totalQuantitynumberSum of all item quantities
subTotalstringPre-tax, pre-fee subtotal
taxTotalstringCalculated tax
orderTotalWithServiceFeestringFinal total including all fees
discountCodestring | nullApplied promo code
fulfilmentMethodstringCurrent fulfillment method
pickupType'ASAP' | 'LATER'Order timing
currencystringCart currency (usd, gbp, etc.)

Next steps

Checkout Flow

Collect customer details and process payments.

Fulfillment Methods

Configure delivery, table-side, and room service.