This guide covers the full cart lifecycle — from creating a session to adding items with modifiers, updating quantities, applying discounts, and clearing the cart.Documentation Index
Fetch the complete documentation index at: https://docs.cravejs.com/llms.txt
Use this file to discover all available pages before exploring further.
Cart lifecycle overview
Start an ordering session
Creates a cart and returns a
cartId you use for all subsequent operations.Start an ordering session
Add an item
Add an item with modifiers
Modifiers represent customizations (e.g., size, toppings, extras). Pass them in theselections array.
Item unavailable actions
When an item becomes unavailable after being added (e.g., sold out), Crave handles it based on theitemUnavailableAction field:
| Action | Behavior |
|---|---|
remove_item | Remove the specific item from the cart |
cancel_entire_order | Cancel the whole order if any item is unavailable |
Get the cart
Update item quantity
0 to remove the item.
Apply a discount
Remove a discount
Get recommended products
Show upsell suggestions based on the current cart contents.Delete the cart
Cart data model
TheStorefrontCart type includes these key fields:
| Field | Type | Description |
|---|---|---|
id | string | Unique cart ID |
items | CartItem[] | Line items with quantity, modifiers, price |
totalQuantity | number | Sum of all item quantities |
subTotal | string | Pre-tax, pre-fee subtotal |
taxTotal | string | Calculated tax |
orderTotalWithServiceFee | string | Final total including all fees |
discountCode | string | null | Applied promo code |
fulfilmentMethod | string | Current fulfillment method |
pickupType | 'ASAP' | 'LATER' | Order timing |
currency | string | Cart currency (usd, gbp, etc.) |
Next steps
Checkout Flow
Collect customer details and process payments.
Fulfillment Methods
Configure delivery, table-side, and room service.