How to Retrieve Cart Data with Admin API

How to Retrieve Cart Data with Admin API

daniel-lee92
Tourist
4 0 2

Hi experts,

 

Please let me know how to retrieve all cart list in shop using Admin API(with REST API or GraphQL).

It is hard to find the way from API docs.

 

Thanks.

Replies 3 (3)

ShopifyDevSup
Shopify Staff
1453 238 509

Hi @daniel-lee92 . The cart object only exists in the context of the storefront so you would need the Storefront API to query a cart.. Unless you are looking for a way to find 'abandoned carts' in which case you can check Abandoment with the type Cart. 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

daniel-lee92
Tourist
4 0 2

Thanks @ShopifyDevSup ,

Then, could I ask how to get cart ID using Admin API or Storefront API either.

I tried to find how to get them but what I found is the cart ID is created when the cart is made with Storefront API.

Plus, as I reviewed Abandonment is not the one I wanted to get data because it is made only when the cart goes checking process and discard.

ShopifyDevSup
Shopify Staff
1453 238 509

Hey @daniel-lee92 - you're correct that the cart ID is generally created when the cart is created using the Storefront API. Usually, when the cart is created, you'd receive a JSON response that contains the Cart ID. Another way to retrieve it upon creation is through a carts/create webhook subscription, which would also contain a JSON payload you can use. 

You would need to know these values first in order to modify them or query them, and at the moment, the only way to retrieve the cart ID/webURL/token is to have created the cart in the first place. This is meant to "lock down" the cart so it can only be modified by the app that created it in the first place or by the web checkout/cart interface, to avoid unexpected behaviour. 

Hope this helps - let us know if we can clarify anything on our end. 

 

Al | Shopify Developer Support

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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