Skip to content

cart

Queryin Cart

Get the current user's shopping cart with all line items and totals

Returns

Cart

FieldTypeDescription
idID!Unique identifier of the cart. Stable for the cart's whole life, so a client may key a cache on it.
versionStringOpaque optimistic-concurrency token, present only for engines that version their resources. Pass it back verbatim; never parse or compare it.
createdAtDateTime!Creation date of the cart
lastModifiedAtDateTime!Last modified date of the cart
currencyCurrency!The currency used in the cart
customerEmailStringCustomer email
isGuestBoolean!Indicates if the cart is a guest cart
lineItems[CartLineItem!]!Line items in the cart
totalQuantityInt!Total quantity of all line items
changes[CartLineChange!]!What changed since the session last acknowledged the cart, oldest first: sold-out lines, price changes against the price at the time of adding, and lowered quantities. Listed until cartChangesAcknowledge, so a notice shows them once.
unavailableLineItems[CartLineItem!]!Lines that cannot be ordered now, such as sold out. They are kept out of the totals and out of the order. Empty where the engine cannot keep them: those are removed instead, and listed in changes as REMOVED.
subTotalTaxedTotalPrice!Sum of all line items (i.e. price excluding all shipping and payment costs)
totalTaxedTotalPrice!Sum of all line items (i.e. price including all shipping and payment costs)
discountTotalTaxedPriceDiscount applied to the cart total, on top of any discount already reflected in the line items. A positive magnitude: subtract it, never add it. Showing it as a negative amount is a presentation choice, not a property of the data. Taxed like the amounts it has to be arithmetic with, so a summary reconciles in one basis: subTotal minus this plus shippingCosts equals total. The rate is the effective rate over the discounted goods -- exact for a single-rate basket, a blend where the basket mixes rates.
discountCodes[CartDiscountCode!]!Discount codes that are applied to the cart
appliedDiscounts[AppliedDiscount!]Every discount the cart applies, on its total, its lines or its shipping, with what it takes off in all: the names a summary explains the price with. A reduced price the product itself carries is not one of them. A discount reached through a code is also in discountCodes; the rest are automaticDiscounts. Null where the engine does not report its discounts.
automaticDiscounts[AppliedDiscount!]The discounts the cart gets without a code, such as an automatic promotion, each with what it takes off: the entries of appliedDiscounts that no code brought, so adding the two lists counts these twice. Together with discountCodes they explain discountTotal row by row. Null where the engine does not report its discounts.
billingAddressAddressCustomer billing address
shippingAddressAddressCustomer shipping address
shippingCostsTaxedPriceShipping costs, if any
estimatedShippingCostsTaxedPriceWhat shipping will likely cost while no shipping method is set, so a summary can show a total before checkout. An estimate: null once shippingCosts is known, and where the engine has nothing to base one on.
freeDeliveryCartFreeDeliveryHow far the cart is from free delivery: the goods total at which shipping becomes free, and how much is still to add. Read from the chosen shipping method's rate, or the default method's for the store's country while none is chosen. Null where that rate has no free threshold, and where the cart ships outside the store's country without a method chosen.
complementaryProducts[ProductVariant!]!Products to suggest alongside what is in the cart, such as below its lines: the complementary products of its lines, the most recently added line's first, without those already in the cart, and only what can be sold in the store and is in stock. At most limit of them, and never more than 10.Arguments: limit
selectedShippingMethodShippingMethodSelected shipping method for the cart
preselectedShippingMethodShippingMethodThe shipping method the delivery step starts on: the selected one once there is one, otherwise the default method for the shipping address's country or, before there is an address, the store's. Its price is what the cart is charged for it, after the rate's tiers and free threshold, and with the delivery options composed its carrier and deliveryEstimate say who brings it and when. Null when no method ships there.
selectedPaymentMethodPaymentMethodSelected payment method for the cart
amountToPayMoney!What the buyer still has to pay: the gross total less everything the cart's payments have reserved or collected. Equal to the gross total while no payment holds anything. A partial payment such as a gift card lowers this and never total, subTotal, discountTotal or any tax: the price of the goods is the same whoever pays for it.
payments[CartPayment!]!The payments on the cart, oldest first. A cart can carry several: partial payments such as gift cards, and the payment that pays the rest.
availableShippingMethods[ShippingMethod!]!Shipping methods that are available for the cart
deliveryRemarksStringNote for whoever delivers the goods, as the buyer typed it -- "please leave it under the shelter". Carried to the order. Null until someone records one.
vatNumberStringThe VAT number of the company the buyer orders for, as recorded at checkout. Carried to the order. Null until someone records one. A verified number can make the cart reverse-charged; see vatOutcome.
vatShiftingMoneyThe amount of a reverse-charge line, negative and already reflected in total, where one is carried. A reverse-charged cart is taxed at 0% and gets no such line, so this is null on it.Deprecated: A reverse-charged cart is taxed at 0%; read vatOutcome and the taxed totals.
vatExemptionMoneyThe amount of an export line, negative and already reflected in total, where one is carried. An exported cart is taxed at 0% and gets no such line, so this is null on it.Deprecated: An exported cart is taxed at 0%; read vatOutcome and the taxed totals.
vatOutcomeVatOutcomeWhich VAT rule the cart's amounts follow, and why, so a checkout can explain them. Decided by the delivery country and the buyer's VAT number, or for a cart bought for a business unit, the company's VAT registrations; the billing country never counts. Null until the cart has a delivery address or a pickup at the seller, and where the engine does not decide VAT itself. The rules are the standard EU rules for goods and have not been reviewed by a tax advisor.
purchaseOrderNumberStringThe buyer's own reference for this purchase, usually a purchase order number. Carried to the resulting order so a finance team can match it against their own paperwork. Null until someone records one, which only an associate of the cart's business unit can, through cartSetPurchaseOrderNumber.
minimumOrderB2BCartMinimumOrderThe business unit's minimum order value. Null when the unit has none, when it is set in another currency than the cart's, and for a cart that is not a business unit's. Below it orderPlace is refused; requesting a quote is not.
availablePaymentMethods[PaymentMethod!]!Payment methods that are available for the cartArguments: device
deliveryDates[DeliveryDate!]!The dates the cart can be delivered on, each with its time slots, starting at from (today when absent) and covering the given number of days. Every date in the range is listed, including those with nothing to offer, so a date picker can show them disabled with their reason. Empty while the cart has no shipping address to deliver to.Arguments: from, days
deliverySlotDeliverySlotThe delivery slot chosen for the cart. Null until one is chosen.
pickupPoints[PickupPoint!]!Pickup points the cart can be collected from, nearest first, including those that cannot be chosen. Searched around near, or the shipping address when near is absent; empty when there is neither. carrierKeys narrows the list to those carriers.Arguments: near, carrierKeys, limit
pickupPointPickupPointThe pickup point chosen for the cart. Null until one is chosen.
deliverySplitDeliverySplitType!Whether the cart ships once, when every line is in stock, or ships what is in stock now and the backordered rest later. COMPLETE until chosen.
requestedDeliveryDateDateThe date the buyer asked to receive the delivery on. Null until asked.
earliestCompleteDeliveryDateDateThe first date every line is in stock, which is when a complete delivery can leave at the earliest. Null when nothing is backordered, or when a backordered line has no expected date; the lines say which.
nameStringBuyer-given name, to tell one cart from another. Null until a cart is named.
defaultNameStringWhat to call the cart while it has no name: its first product, then a plus and the number of further products, such as "Accuboormachine + 2". Language-neutral, so a storefront needs no wording for it. Given whether or not the cart is named; null for an empty cart, where a storefront shows its own label.
previewImages[ProductImage!]!Images of the cart's first products, one per line in the order they were added and none repeated, so a cart list shows what each cart holds. Add-ons are left out, as is a line without an image. At most 10, whatever the limit asks for; empty for an empty cart.Arguments: limit
ownerCustomerThe person whose cart this is. Null for a guest cart, which belongs to a session rather than to anyone.
statusCartStatusType!Whether the cart is in use or archived. A cart nobody has touched for 60 days, or the period the service configures, is archived: it leaves the unit's cart list unless that is asked for. The caller's current cart is never archived, so choosing one with cartSetCurrent makes it read ACTIVE.
approvalRequirementCartApprovalRequirementWhat placing the cart now waits for. Null when it needs no approval, and for a cart that is not a business unit's.

Example

query {
cart {
id
currency
lineItems {
... on CartSingleLineItem {
id
quantity
price {
gross {
centAmount
currency
}
}
variant {
id
sku
}
}
}
total {
gross {
centAmount
currency
}
}
shippingAddress {
givenName
familyName
city
}
billingAddress {
givenName
familyName
city
}
}
}

The query is the example the schema documents. The response shows its shape with placeholder values.

Served by

@evolve-framework/commercetoolsResolved
@evolve-framework/medusaResolved
@evolve-framework/sfccResolved

Used by

The storefront packages that send it, in these GraphQL documents:

  • @evolve-storefront/feature-cart: GetCartApprovalRequirement, GetCartChanges, GetCartComplementaryProducts, GetCartDeliveryDates, GetCartPickupPoints, GetCartDeliveryPreference, GetCartShippingEstimates, GetCartDeliveryPromise, GetCart, GetCartAvailableShippingMethods, GetCartAvailablePaymentMethods, GetCartWalletMethods, GetCartMinimumOrder