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:

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:

Next steps

Checkout Flow

Collect customer details and process payments.

Fulfillment Methods

Configure delivery, table-side, and room service.