Skip to content

Get Cart ​

Read the current cart with its line items and recalculated totals.

Endpoint ​

POST /api/shop/cart

Reading the cart is a POST, not a GET. The cart is identified by the token in the Authorization header rather than by a path parameter, and the endpoint takes an empty JSON body.

Request Headers ​

HeaderRequiredDescription
Content-TypeYesapplication/json
AcceptYesapplication/json
X-STOREFRONT-KEYYesYour storefront API key
AuthorizationYesBearer <cartToken> for a guest, or the customer's Bearer token when signed in

Request Body ​

json
{}

Response Fields ​

The response is the cart itself, returned as a bare object with no wrapper.

FieldTypeDescription
idintegerCart ID.
cartTokenstringToken identifying this cart.
customerIdintegerOwning customer, or null for a guest cart.
channelIdintegerChannel the cart belongs to.
itemsCountintegerNumber of line items.
itemsQtyintegerTotal units across those lines.
itemsarrayLine items — fields below.
subtotal / baseSubtotaldecimalItems subtotal.
discountAmount / baseDiscountAmountdecimalDiscount applied.
taxAmount / baseTaxAmountdecimalTax calculated.
shippingAmount / baseShippingAmountdecimalShipping cost, once a method is chosen.
grandTotal / baseGrandTotaldecimalGrand total.
formattedSubtotal, formattedDiscountAmount, formattedTaxAmount, formattedShippingAmount, formattedGrandTotalstringThe same amounts, currency-formatted.
couponCodestringApplied coupon, or null.
isGuestbooleanWhether the cart belongs to a guest.

Item Fields ​

FieldTypeDescription
idintegerCart item ID. This is what the update and remove endpoints expect.
cartIdintegerParent cart ID.
productIdintegerProduct on this line.
name / skustringProduct name and SKU as added.
quantityintegerUnits on this line.
price / totaldecimalUnit price and line total.
formattedPrice / formattedTotalstringThe same values, currency-formatted.
priceInclTax / totalInclTaxdecimalTax-inclusive equivalents, with formatted* variants.
discountAmount / taxAmountdecimalPer-line discount and tax.
optionsarraySelected options for configurable, bundle, and customizable products. null when none apply.
typestringProduct type of the line.
baseImagestringJSON string of the product's image URLs at each size.
productUrlKeystringStorefront slug, for linking back to the product.
canChangeQtybooleanfalse for event and appointment bookings, whose quantity is fixed.

Use Cases ​

  • Render the cart page — one call returns items and every total needed for the summary panel.
  • Refresh the mini-cart — read after any change to pick up recalculated totals.
  • Resume a guest session — a stored cartToken restores the cart on a return visit.

Best Practices ​

  1. Treat 404 Cart not found as "no cart yet" — a cart only exists once an item has been added, and it is cleared again when the last item is removed
  2. Read the totals from the response, not from your own arithmetic — discounts and tax are recalculated server-side on every change
  3. Use the formatted* fields for display — they carry the active currency's symbol and formatting
  4. Keep the numeric item id — update and remove both key off it

Released under the MIT License.