sdk.cart namespace manages the shopping cart. Cart operations work for both authenticated customers and guest visitors. The SDK automatically handles cart token management — tokens are extracted from API responses and sent with subsequent requests via the X-Cart-Token header.
Methods
cart.get()
Retrieve the current cart contents.
Cart
cart.addItem(productId, quantity?, options?)
Add a product to the cart.
Returns:
Cart
cart.updateItem(itemId, quantity)
Update the quantity of a cart item.
Returns:
Cart
cart.removeItem(itemId)
Remove an item from the cart.
Cart
cart.clear()
Remove all items from the cart and clear the stored cart token.
void
cart.getCount()
Get the number of items in the cart without fetching the full cart.
number
cart.applyCoupon(code)
Apply a discount coupon to the cart.
Returns:
Cart
If the coupon is invalid or expired, the API returns an error. Wrap this call in a try/catch to display the error message to the customer.
cart.removeCoupon()
Remove the currently applied coupon.
Cart

