checkout
Overview
Retrieve the shopper's cart with line items, pricing, coupon info, and checkout metadata. Use it to display a live summary during checkout steps.
- Type: GraphQL Query
- Endpoint: https://appssubdomain.com
- Authentication:
Authorization: Bearer <TOKEN>(session/account dependent)
Query
query getcheckout {
cart {
data {
_id
coupon
kind
couponApplied
couponDiscount
items {
productId
_id
variantId
productData {
price
slug
title
}
variantData {
compareAtPrice
price
}
quantity
price
compareAtPrice
totalPrice
totalCompareAtPrice
totalSavings
}
deviceId
sessionId
status
totalQuantity
totalPrice
totalCompareAtPrice
totalSavings
isFastOrder
createdAt
updatedAt
url
encryptionKey
}
success
message
}
}
Examples
- cURL
- JavaScript (fetch)
curl -X POST \
https://appssubdomain.com\
-H "Content-Type: application/json" \
-H "Authorization: Bearer <TOKEN>" \
--data-binary @- << 'EOF'
{ "query": "query getcheckout { cart { data { _id totalPrice totalQuantity items { _id quantity totalPrice } } success message } }" }
EOF
const res = await fetch('https://appssubdomain.com', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + token,
},
body: JSON.stringify({
query: `query getcheckout { cart { data { _id totalPrice totalQuantity } success message } }`,
}),
});
const json = await res.json();
Notes
- Replace
<TOKEN>with the appropriate session/account credential. - Extend the selected fields (e.g., item productData) based on what you render on the checkout page.
- Use
success/messageto handle empty or expired carts gracefully.