Skip to main content

Overview

The Shopping Cart API provides comprehensive cart management functionality for customers. Each customer can have multiple carts (one per store) with real-time synchronization across devices.

Add to Cart

Add a product to the customer’s shopping cart for a specific store.
customerId
Id<'customers'>
required
Customer ID
storeId
Id<'stores'>
required
Store ID
productId
Id<'products'>
required
Product ID to add
quantity
number
required
Quantity to add (must be positive)

Update Cart Item Quantity

Update the quantity of a specific item in the cart. Set quantity to 0 to remove the item.
customerId
Id<'customers'>
required
Customer ID
storeId
Id<'stores'>
required
Store ID
productId
Id<'products'>
required
Product ID to update
quantity
number
required
New quantity (0 to remove item)

Remove from Cart

Remove a specific item from the cart completely.
customerId
Id<'customers'>
required
Customer ID
storeId
Id<'stores'>
required
Store ID
productId
Id<'products'>
required
Product ID to remove

Clear Cart

Clear all items from the cart for a specific store.
customerId
Id<'customers'>
required
Customer ID
storeId
Id<'stores'>
required
Store ID

Get Cart

Retrieve the cart for a specific customer and store with current product information and pricing.
customerId
Id<'customers'>
required
Customer ID
storeId
Id<'stores'>
required
Store ID

Get Customer Carts

Retrieve all carts for a customer across all stores.
customerId
Id<'customers'>
required
Customer ID

Get Cart Summary

Get a summary of all cart activity for a customer.
customerId
Id<'customers'>
required
Customer ID

Get Cart for Checkout

🆕 New Function - Get cart with checkout calculations and validation in one call.
customerId
Id<'customers'>
required
Customer ID
storeId
Id<'stores'>
required
Store ID
deliveryType
string
required
Delivery method: delivery or pickup
deliveryFee
number
Delivery fee (defaults to 5.99 for delivery, 0 for pickup)

Real-time Updates

The cart system supports real-time updates across all devices. Use the React hooks for automatic synchronization:

Error Handling

Error: Product is inactive or out of stock
Error: Not enough stock for requested quantity
Error: Store is not accepting orders

Best Practices

Real-time Sync

Use React hooks for automatic cart synchronization across devices and tabs.

Validation

Always validate cart contents before checkout to handle stock changes.

Performance

Use getCartForCheckout for checkout flows to reduce API calls.

User Experience

Show loading states and handle errors gracefully for better UX.
Cart items are automatically validated for availability and stock levels. Unavailable items are marked but not removed automatically.
Use the getCartForCheckout function for checkout flows as it provides cart data, validation, and totals calculation in a single optimized call.