- Ordering
Introducing the Cart API
The Cart API simplifies shopping experience development through streamlined endpoints. This enhancement provides direct cart interaction while supporting both single-cart and multi-cart implementations.
Implementation benefits
Previous workflow (without Cart API):
GET v1/orders/{direction}?Status=Unsubmitted&SortBy=!DateCreated- Process most recent Order ID
- Create order if none exists
- Add line items
Simplified workflow (with Cart API):
POST v1/cart/lineitems
Key features
Core functionality:
- Represents unsubmitted orders
- Proxies actions to corresponding orders
- Returns empty structures instead of null/404:
- Empty order with null ID
- Empty line item list
- Supports immediate or deferred order creation
- Automatic order creation with line item addition
Implementation patterns
Single cart implementation
Standard workflow:
- Initial load:
GET v1/cartfor item count - Add items:
POST v1/cart/lineitems - Prepare cart:
POST v1/cart/payments,POST v1/cart/validate - Submit order:
POST v1/cart/submit
Implementation note: Use Cart endpoints instead of Order endpoints to prevent multiple unsubmitted orders. System selects most recent unsubmitted order as active cart.
Multi-cart implementation
Extended workflow:
-
List unsubmitted orders:
http -
Create orders if needed:
POST v1/orders/{direction}PUT v1/orders/{direction}/{orderID}
-
Designate active cart:
http -
Add items to first cart:
http -
Switch active cart:
http -
Add items to second cart:
http -
Prepare cart:
- Add payments
- Validate order
-
Submit order:
http
Implementation notes:
- Remaining unsubmitted orders become active cart
- Use
PUT v1/cart/{orderID}for specific cart selection - Anonymous shopping does not support multi-cart
Available endpoints
Cart endpoints proxy to Order endpoints with simplified interaction:
| Endpoint | Order equivalent | Purpose |
|---|---|---|
GET v1/cart | GET v1/orders/outgoing?PageSize=1&Status=Unsubmitted&SortBy=!DateCreated | Retrieve cart |
PUT v1/cart | POST v1/orders/outgoing or PUT v1/orders/outgoing/{orderID} | Create/update cart |
PUT v1/cart/{orderID} | None | Set active cart |
PATCH v1/cart | PATCH v1/orders/outgoing/{orderID} | Partial cart update |
DELETE v1/cart | DELETE v1/orders/outgoing/{orderID} | Remove cart |
Line item operations
| Endpoint | Purpose |
|---|---|
GET v1/cart/lineitems | List items |
GET v1/cart/lineitems/{lineitemID} | Get specific item |
POST v1/cart/lineitems | Add item |
PUT v1/cart/lineitems/{lineitemID} | Create/update item |
PATCH v1/cart/lineitems/{lineitemID} | Partial item update |
DELETE v1/cart/lineitems/{lineitemID} | Remove item |
Cart processing
| Endpoint | Purpose |
|---|---|
GET v1/cart/worksheet | Get order details |
POST v1/cart/estimateshipping | Calculate shipping |
POST v1/cart/shipmethods | Set shipping method |
PUT v1/cart/shipto | Set shipping address |
PUT v1/cart/billto | Set billing address |
POST v1/cart/calculate | Update totals |
Payment handling
| Endpoint | Purpose |
|---|---|
GET v1/cart/payments | List payments |
POST v1/cart/payments | Add payment |
PATCH v1/cart/payments/{paymentID} | Update payment |
DELETE v1/cart/payments/{paymentID} | Remove payment |
POST v1/cart/payments/{paymentID}/transactions | Process payment |
Promotion management
| Endpoint | Purpose |
|---|---|
GET v1/cart/promotions | List promotions |
POST v1/cart/promotions/{promoCode} | Apply promotion |
Order completion
| Endpoint | Purpose |
|---|---|
PATCH v1/cart/fromuser | Update user details |
POST v1/cart/validate | Verify cart |
POST v1/cart/submit | Complete order |