Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Abandoned checkout using graphQL

Abandoned checkout using graphQL

ajaysharma31
Visitor
2 0 2

Hi, 
I'm using the below query(screenshot) and getting the error: "Field 'abandonedCheckoutsConnection' doesn't exist on type 'QueryRoot'".

I have tried multiple different queries but got the same response.
Please suggest the correct query to fetch all the abandoned checkout data using graphQL.
Below are the attachments of the query and response.

ajaysharma31_0-1721309963623.pngajaysharma31_1-1721309978419.png

 

Replies 3 (3)

Liam
Community Manager
3108 344 904

To fetch all the abandoned checkout data, you can use the abandonmentByAbandonedCheckoutId and abandonment queries from the Shopify GraphQL Admin API. Below are examples of how to use these queries:

 

query GetAbandonmentByCheckoutId {
  abandonmentByAbandonedCheckoutId(abandonedCheckoutId: "your_abandoned_checkout_id") {
    abandonedCheckoutPayload {
      abandonedCheckoutUrl
      id
      lineItems(first: 5) {
        edges {
          node {
            title
            quantity
            priceSet {
              shopMoney {
                amount
                currencyCode
              }
            }
          }
        }
      }
      lineItemsQuantity
      totalPriceSet {
        shopMoney {
          amount
          currencyCode
        }
      }
    }
    abandonmentType
    createdAt
    customer {
      email
      firstName
      lastName
    }
    emailSentAt
    emailState
  }
}

 

query GetAbandonmentById {
  abandonment(id: "your_abandonment_id") {
    abandonedCheckoutPayload {
      abandonedCheckoutUrl
      id
      lineItems(first: 5) {
        edges {
          node {
            title
            quantity
            priceSet {
              shopMoney {
                amount
                currencyCode
              }
            }
          }
        }
      }
      lineItemsQuantity
      totalPriceSet {
        shopMoney {
          amount
          currencyCode
        }
      }
    }
    abandonmentType
    createdAt
    customer {
      email
      firstName
      lastName
    }
    emailSentAt
    emailState
  }
}

 

Would these work for you?

Liam | Developer Advocate @ 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 Shopify.dev or the Shopify Web Design and Development Blog

ajaysharma31
Visitor
2 0 2

Hi @Liam
Thanks for the reply.
If I use abandonmentByAbandonedCheckoutId(abandonedCheckoutId: "your_abandoned_checkout_id") then I have to pass the ID of the abandoned checkout and it will return data related to that abandoned_checkout.
But here I need to fetch all the abandoned checkout data between 2 updated_at dates without using a particular Id of abandoned checkout..
Please suggest.

jfkScollar
Shopify Partner
19 0 4

Thanks @Liam . How do you get the list of "your_abandonment_id"? If you do not have that id, then these queries are of no use. What is the query to get the list of abandonment ids?

 

Thanks,

John