1. 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):

  1. GET v1/orders/{direction}?Status=Unsubmitted&SortBy=!DateCreated
  2. Process most recent Order ID
  3. Create order if none exists
  4. Add line items

Simplified workflow (with Cart API):

  1. 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:

  1. Initial load: GET v1/cart for item count
  2. Add items: POST v1/cart/lineitems
  3. Prepare cart: POST v1/cart/payments, POST v1/cart/validate
  4. 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:

  1. List unsubmitted orders:

    http
    GET v1/orders/{direction}?Status=Unsubmitted
  2. Create orders if needed:

    • POST v1/orders/{direction}
    • PUT v1/orders/{direction}/{orderID}
  3. Designate active cart:

    http
    PUT v1/cart/ABC
  4. Add items to first cart:

    http
    POST v1/cart/lineitems
  5. Switch active cart:

    http
    PUT v1/cart/123
  6. Add items to second cart:

    http
    POST v1/cart/lineitems
  7. Prepare cart:

    • Add payments
    • Validate order
  8. Submit order:

    http
    POST v1/cart/submit

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:

EndpointOrder equivalentPurpose
GET v1/cartGET v1/orders/outgoing?PageSize=1&Status=Unsubmitted&SortBy=!DateCreatedRetrieve cart
PUT v1/cartPOST v1/orders/outgoing or PUT v1/orders/outgoing/{orderID}Create/update cart
PUT v1/cart/{orderID}NoneSet active cart
PATCH v1/cartPATCH v1/orders/outgoing/{orderID}Partial cart update
DELETE v1/cartDELETE v1/orders/outgoing/{orderID}Remove cart

Line item operations

EndpointPurpose
GET v1/cart/lineitemsList items
GET v1/cart/lineitems/{lineitemID}Get specific item
POST v1/cart/lineitemsAdd 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

EndpointPurpose
GET v1/cart/worksheetGet order details
POST v1/cart/estimateshippingCalculate shipping
POST v1/cart/shipmethodsSet shipping method
PUT v1/cart/shiptoSet shipping address
PUT v1/cart/billtoSet billing address
POST v1/cart/calculateUpdate totals

Payment handling

EndpointPurpose
GET v1/cart/paymentsList payments
POST v1/cart/paymentsAdd payment
PATCH v1/cart/payments/{paymentID}Update payment
DELETE v1/cart/payments/{paymentID}Remove payment
POST v1/cart/payments/{paymentID}/transactionsProcess payment

Promotion management

EndpointPurpose
GET v1/cart/promotionsList promotions
POST v1/cart/promotions/{promoCode}Apply promotion

Order completion

EndpointPurpose
PATCH v1/cart/fromuserUpdate user details
POST v1/cart/validateVerify cart
POST v1/cart/submitComplete order
If you have suggestions for improving this article, let us know!