Skip to main content

Get Cart

GetCart Query

This query retrieves the current cart details by cart ID. It is typically used after cart mutations to render cart summaries, mini-carts, or to prepare for checkout redirection.

Note: In customer flows, the cart is associated with a sessionid header. You usually resolve the current cart via session on the backend and pass cart.id to your frontend to use in this query.

Input Parameters​

  • $storeId: ID! – The store in which the cart lives.
  • $id: ID – Cart identifier (Cart_...). If omitted, the backend may fall back to the active cart resolved from the current session (implementation-specific).

Response Structure​

Returns a Cart object with:

  • id – Cart ID to be used in checkout URLs.
  • refCode – Optional referral or tracking code associated with the cart.
  • recoveryId – Identifier used for cart recovery flows.
  • sessionId – Associated session identifier.
  • status / cartStep / lastStep – Current and last completed cart lifecycle steps.
  • items – Line items (for simple items):
    • id
    • quantity
    • price / totalPrice (Money)
    • variant (basic product information)
  • receipt – Monetary breakdown:
    • subtotal, discount, shipping, tax, automaticDiscount, total.
  • shippingDetails – Saved shipping address and area info (country/state/city/region IDs).
  • shippingRate – Selected shipping rate cost (Money).
  • contactInfo – Basic contact information (name, email, phone).
  • customer – Linked customer (id, name, email, phone).
  • promoCode – Applied promo code information (id, code, type).
  • shippingDiscount – Shipping discount metadata (id, title).
  • cartErrors – Cart-level errors (code + params such as message, resourceId, requested/available quantity).
  • paymentIntentId / paymentIntent – Payment intent identifiers and status.
  • isReserved / reservedAt – Reservation status and timestamp.
  • emailStatus / emailSentAt – Email sending state for the cart.
  • createdAt / updatedAt – Cart creation and last update timestamps.

Example Variables​

{
"storeId": "Store_cm84j35iy02m001i89iiu2cts",
"id": "Cart_d8f8ce2f-681e-4554-93b7-230e0b34a151"
}

Implementation Notes​

  • Call GetCart after AddToCart or ReplaceCartItems to get the latest totals.
  • Use the returned cart.id to construct checkout URLs on your landing pages.
  • You can cache the cart client-side, but always re-fetch before checkout to avoid stale totals.

GraphQL Endpoint​

https://graphql.wuilt.com

Operation: GetCart​

Try It Out​

Query​

query GetCart($storeId: ID!, $id: ID) {
customerQueries(storeId: $storeId) {
cart(id: $id) {
id
refCode
recoveryId
sessionId
status
cartStep
lastStep
items {
... on CartSimpleItem {
id
quantity
price {
amount
currencyCode
}
totalPrice {
amount
currencyCode
}
product {
id
title
shortDescription
descriptionHtml
handle
images {
id
src
altText
width
height
}
}
variant {
id
sku
price {
amount
currencyCode
}
compareAtPrice {
amount
currencyCode
}
image {
id
src
altText
width
height
}
}
}
}
receipt {
subtotal {
amount
currencyCode
}
discount {
amount
currencyCode
}
shipping {
amount
currencyCode
}
tax {
amount
currencyCode
}
automaticDiscount {
amount
currencyCode
}
total {
amount
currencyCode
}
}
shippingDetails {
id
addressLine1
addressLine2
phone
secondPhone
postalCode
notes
area {
countryId
stateId
cityId
regionId
}
}
shippingRate {
cost {
amount
currencyCode
}
}
contactInfo {
id
name
email
phone
}
customer {
id
name
email
phone
}
promoCode {
id
code
type
}
shippingDiscount {
id
title
}
cartErrors {
code
params {
message
resourceId
requestedQuantity
availableQuantity
}
}
paymentIntentId
paymentIntent {
id
status
}
isReserved
reservedAt
emailStatus
emailSentAt
createdAt
updatedAt
}
}
}

Query Variables

1
2
3
4

Note: Make sure to change the storeId with your store ID. For guidance on how to get your store ID, reference the Store ID guide.

Authentication​

To use this query, you will need an API key. Click the "API Key" button in the navigation bar to enter your credentials.