Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Using the Storefront API and looking for some help retrieving a checkout that has been created (for example: via checkoutCreate) and not yet turned into an order.
The use case is that we're wanting to create a Cart page on a website. When the customer goes to the Cart page, as long as we have a Checkout ID in their session, we retrieve the Checkout and show the line items in the cart.
Here's the query we're using:
Hi @DynamitDave,
I tried your query, and although it's using a bunch of deprecated parameters the syntax is fine and this should work. The error message you are getting leads me to believe it's not an issue with the query itself but how you are sending it in code. It's possible you are sending the query with some extra whitespace or characters. Can you try the same query in a client such as insomnia or postman and see if you get the same results? If so, can you pass along some more details so I can look it up on my end, most helpful is the X-Request-ID returned in the headers after you call the API.
My query is to
{mytestshop}.myshopify.com/api/2019-10/graphql.json
{ node(id: "Z2lk...0ODc=") { id ... on Checkout { id ready currencyCode subtotalPrice taxesIncluded totalTax totalPrice lineItems(first: 250) { edges { node { id title quantity variant { id price } } } } } } }
Hope this helps,
Ryan
Ryan | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
I'm doing your exact query except with my checkout id, of course, and I keep getting the error: "No such type Checkout, so it can't be a fragment condition" I've googled a bunch and can't find a thing. Do you have any ideas?
Here's the query I ended up using (that worked):
https://{mytestshop}.myshopify.com/api/2019-07/graphql.json
{
node(id: "Z2lkOi8vc2h=") {
id
... on Checkout {
id
ready
currencyCode
subtotalPrice
taxesIncluded
totalTax
totalPrice
lineItems(first: 250) {
edges {
node {
id
title
quantity
variant {
id
price
}
}
}
}
}
}
}
Before querying to retrieve the cart, I performed a request to create a new checkout and add an item.
mutation {
checkoutCreate(input: {
lineItems: [{ variantId: "Z2lkO=", quantity: 1 }]
}) {
checkout {
id
webUrl
totalPriceV2
{
amount
currencyCode
}
updatedAt
lineItems(first: 5) {
edges {
node {
title
quantity
}
}
}
}
}
}
I tested both of these queries today and they are still working for me.
Hope this helps,