Skip to main content

Carts

The carts model represents shopping cart data, including line items, addresses, shipping methods, promotions, and payment methods. It enables cart management for e-commerce checkout flows, supporting both guest and authenticated users.

Cart Service

The CartService provides methods to interact with cart data.

getCart

Retrieves a specific cart by ID.

getCart(
params: GetCartParams,
authorization?: string
): Observable<Carts.Model.Cart | undefined>

Parameters

ParameterTypeDescription
paramsGetCartParamsParameters containing the cart ID
authorizationstringOptional authorization header

Returns

An Observable that emits the requested cart or undefined if not found.

getCartList

Retrieves a paginated list of carts with optional filtering (authenticated users).

getCartList(
query: GetCartListQuery,
authorization?: string
): Observable<Carts.Model.Carts>

Query Parameters

ParameterTypeDescription
customerIdstringFilter by customer ID
typeCartTypeFilter by cart type
offsetnumberNumber of items to skip
limitnumberMaximum number of items to return
sortstringSorting criteria

createCart

Creates a new cart.

createCart(
data: CreateCartBody,
authorization?: string
): Observable<Carts.Model.Cart>

Body Parameters

ParameterTypeDescription
currencyCurrencyCart currency (required)
regionIdstringRegion ID for pricing/shipping (optional)
customerIdstringCustomer ID for authenticated users (optional)
typeCartTypeCart type (default: ACTIVE)
metadataobjectCustom metadata (optional)

addCartItem

Adds an item to a cart. If no cartId is provided, finds active cart or creates a new one.

addCartItem(
data: AddCartItemBody,
authorization?: string
): Observable<Carts.Model.Cart>

Body Parameters

ParameterTypeDescription
cartIdstringExisting cart ID (optional)
skustringProduct variant SKU (required)
variantIdstringProduct variant ID (optional)
quantitynumberQuantity (required)
currencyCurrencyRequired when creating new cart
regionIdstringRequired when creating new cart

updateCartItem

Updates the quantity of a cart item.

updateCartItem(
params: UpdateCartItemParams,
data: UpdateCartItemBody,
authorization?: string
): Observable<Carts.Model.Cart>

removeCartItem

Removes an item from the cart.

removeCartItem(
params: RemoveCartItemParams,
authorization?: string
): Observable<Carts.Model.Cart>

updateCartAddresses

Updates shipping and/or billing addresses on the cart (used during checkout).

updateCartAddresses(
params: UpdateCartAddressesParams,
data: UpdateCartAddressesBody,
authorization?: string
): Observable<Carts.Model.Cart>

Body Parameters

ParameterTypeDescription
shippingAddressIdstringUse saved address (authenticated users only)
shippingAddressAddressOr provide new address inline
billingAddressIdstringUse saved address (authenticated users only)
billingAddressAddressOr provide new address inline
emailstringFor guest checkout (optional)

addShippingMethod

Adds a shipping method to the cart.

addShippingMethod(
params: AddShippingMethodParams,
data: AddShippingMethodBody,
authorization?: string
): Observable<Carts.Model.Cart>

Body Parameters

ParameterTypeDescription
shippingOptionIdstringShipping option ID from Checkout.getShippingOptions()

applyPromotion / removePromotion

Applies or removes a promotion code from the cart.

applyPromotion(params: ApplyPromotionParams, data: ApplyPromotionBody, authorization?: string): Observable<Carts.Model.Cart>
removePromotion(params: RemovePromotionParams, authorization?: string): Observable<Carts.Model.Cart>

getCurrentCart / prepareCheckout

Retrieves the current active cart for the authenticated user, or prepares a cart for checkout.

getCurrentCart(authorization?: string): Observable<Carts.Model.Cart | undefined>
prepareCheckout(params: PrepareCheckoutParams, authorization?: string): Observable<Carts.Model.Cart>

Data Model Structure

The carts model supports:

  1. Cart — Container for items, addresses, shipping, payment
  2. CartItem — Line item with product, quantity, pricing
  3. Guest checkout — Carts without customerId; email required for order
  4. Promotions — Discount codes with percentage, fixed amount, or free shipping

Types

Cart

FieldTypeDescription
idstringUnique identifier
customerIdstringCustomer ID (optional for guests)
typeCartTypeCart type
currencyCurrencyCart currency
itemsdata, totalLine items with pagination
subtotalPriceSubtotal before discounts (optional)
discountTotalPriceTotal discount (optional)
taxTotalPriceTotal tax (optional)
shippingTotalPriceShipping cost (optional)
totalPriceGrand total
shippingAddressAddressShipping address (optional)
billingAddressAddressBilling address (optional)
shippingMethodShippingMethodSelected shipping (optional)
paymentMethodPaymentMethodSelected payment (optional)
emailstringGuest email (optional)
paymentSessionIdstringActive payment session ref (optional)
createdAtstringISO 8601 timestamp
updatedAtstringISO 8601 timestamp
expiresAtstringExpiration date (optional)

CartItem

FieldTypeDescription
idstringUnique identifier
skustringProduct variant SKU
quantitynumberQuantity
pricePriceUnit price
subtotalPricePre-discount subtotal (optional)
discountTotalPriceItem discount (optional)
totalPriceLine total
productProductProduct details

PaymentMethod

FieldTypeDescription
idstringUnique identifier
namestringDisplay name
descriptionstringDescription (optional)

Promotion

FieldTypeDescription
idstringUnique identifier
codestringPromotion code
namestringDisplay name (optional)
typePromotionTypePercentage, fixed, or free shipping (optional)
valuestringDiscount value (optional)

CartType

ValueDescription
ACTIVEActive shopping cart
SAVEDSaved for later
ABANDONEDAbandoned cart

PromotionType

ValueDescription
PERCENTAGEPercentage discount
FIXED_AMOUNTFixed amount discount
FREE_SHIPPINGFree shipping

Carts

Paginated list of carts.

type Carts = Pagination.Paginated<Cart>;