Skip to main content

Cart Management Helpers

The cart helper endpoints are stateless utilities that simplify cart operations. They compute the result of adding, removing, or updating items without storing any server-side state.

Optional Helpers

These endpoints are provided for convenience. You can implement your own cart logic if you prefer complete control over the shopping cart experience.

Key Concepts

Stateless Design

The cart helpers are pure functions:

(existingCart, operation) → newCart
  • No server-side storage - You manage cart state in your application
  • No session required - Each request is independent
  • Predictable results - Same input always produces same output

Why Use Cart Helpers?

BenefitDescription
Accurate pricingHelpers calculate totals using current CatalogSet prices
Modifier validationValidates required modifiers and selection limits
Consistent structureReturns properly formatted carts ready for order validation
Reduced complexityNo need to implement cart math and validation yourself

When to Implement Your Own

Consider implementing your own cart logic if you need:

  • Offline cart support
  • Complex discount/promotion logic
  • Custom cart persistence
  • Cart merging across sessions

Add Item to Cart

Adds an item to a cart and returns the updated cart with recalculated totals.

POST /helpers/cart/add

Request Body

{
"cart": null,
"item": {
"itemId": "item_burger",
"quantity": 2,
"modifierGroups": [
{
"modifierGroupId": "mod_size",
"selectedModifiers": [
{ "itemId": "size_large", "quantity": 1 }
]
}
],
"specialInstructions": "No onions please"
},
"catalogSetId": "catalog_123"
}
FieldDescription
cartExisting cart object, or null for new cart
item.itemIdItem to add from the catalog
item.quantityNumber of this item
item.modifierGroupsSelected modifiers
catalogSetIdRequired when cart is null

Response

{
"storeId": "store_456",
"catalogSetId": "catalog_123",
"lineItems": [
{
"lineItemId": "li_abc123",
"itemId": "item_burger",
"name": "Classic Burger",
"quantity": 2,
"unitPrice": 14.99,
"totalPrice": 29.98,
"modifierGroups": [...],
"specialInstructions": "No onions please"
}
],
"totals": {
"subtotal": 29.98,
"itemCount": 2
}
}

Remove Item from Cart

Removes a line item from the cart.

POST /helpers/cart/remove

Request Body

{
"cart": { ... },
"lineItemId": "li_abc123"
}

Update Item Quantity

Updates the quantity of an existing line item.

POST /helpers/cart/update

Request Body

{
"cart": { ... },
"lineItemId": "li_abc123",
"quantity": 3
}

Setting quantity: 0 removes the item (same as the remove endpoint).

Error Handling

ErrorDescriptionHow to Handle
ITEM_NOT_FOUNDItem ID doesn't exist in CatalogSetCheck itemId against CatalogSet
ITEM_UNAVAILABLEItem exists but is unavailableShow unavailable message, remove from cart
INVALID_MODIFIERInvalid modifier selectionCheck modifier against CatalogSet
MODIFIER_REQUIREDRequired modifier not providedPrompt user to select required modifier
MODIFIER_LIMIT_EXCEEDEDToo many modifiers selectedCheck modifier group max/min limits
LINE_ITEM_NOT_FOUNDLine item ID not in cartRefresh cart state

API Reference

  • CatalogSets - Menu structure for building carts
  • Orders - Submitting the cart as an order
  • Payments - Payment integration options
  • Types - Cart type definitions