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.Customer ID
Store ID
Product ID to add
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.Customer ID
Store ID
Product ID to update
New quantity (0 to remove item)
Remove from Cart
Remove a specific item from the cart completely.Customer ID
Store ID
Product ID to remove
Clear Cart
Clear all items from the cart for a specific store.Customer ID
Store ID
Get Cart
Retrieve the cart for a specific customer and store with current product information and pricing.Customer ID
Store ID
Get Customer Carts
Retrieve all carts for a customer across all stores.Customer ID
Get Cart Summary
Get a summary of all cart activity for a customer.Customer ID
Get Cart for Checkout
🆕 New Function - Get cart with checkout calculations and validation in one call.Customer ID
Store ID
Delivery method:
delivery or pickupDelivery 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
Product not available
Product not available
Error: Product is inactive or out of stock
Insufficient stock
Insufficient stock
Error: Not enough stock for requested quantity
Store inactive
Store inactive
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.
