Cart, Checkout and APIs

Highlighted
Tourist
13 0 3

Hi,

 

I have to admit that I am a lot confused by all the different APIs.

I have been looking at all pages : Storefront API, Admin API, REST Api, CART Api, and finally choose the GraphQL API, and if I am not mistaken, the StoreFront Graphql API.

 

Now, I have a shopify Store and a home-made smartphone app that connects to shopify

I do have installed graphiql on my computer, and I have succeeded in making queries to API 2020-01.

I hav connected to Storefront API and i have retrieved informations about customers, products and shops in both graphiql and my smartphone App.

 

Now, I need now to retrieve informations about cart. To be more precise, I need :

- To get the "cart in progress" attached to a customer

- To add/get/delete product to the cart of a customer using my app

 

I am again confused with all the APIs.

In the different topic, I see that I can do it by both the StoreFront Graphql API and the CART ajax API.

 

In the store front graphql API, version 2020-01,

- I cannot find anything attached to a customer, except the LastIncompleteCheckout (using a query on a specific customer)

- I cannot find anything else concerning cart/checkout

 

In the CART Ajax API, i did not try it yet as it was supposed to be do-able with the store front graphql API,

 

Could you please give me a hand on this one ?

Could you please also give me a hint on the difference between checkout and cart ?

 

Thanks a lot !

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
8 0 0

Hi FloParis,

 

Let me try to clear up your confusion.

 

The Admin API is used for building apps and other integrations for the Shopify admin. The Admin API has two different versions (REST and GraphQL - which are different ways of building web APIs).

 

The Storefront API is part of our Custom Storefront development kit, which is used for building a completely custom shopping experience on practically any interface. The Custom Storefront development kit includes:

  • Storefront API
  • JavaScript Buy SDK
  • Mobile Buy SDKs (Android Buy SDK & iOS Buy SDK)

If you are building a custom storefront using any of the tools from this kit, you will need to create and manage the cart yourself. When the customer is ready to purchase the items in their cart, you can use the Storefront API to create and complete a checkout. The Storefront API no longer has a REST version, there is only the Storefront GraphQL API.

 

Another way of thinking about these APIs is that the Storefront development kit is for building things for customers while the Admin API is for building things for merchants.

 

If you are using the Online Store channel instead of building a custom storefront, the Ajax API (which I believe is the one you called the Cart API) lets you build a custom theme that can access and edit the cart in the current session (rather than accessing any cart for any customer, which is not possible).

 

Hope that helps!

0 Likes
Highlighted
Tourist
13 0 3

Hi Dave,

 

Thanks for the reply.

 

So now, I know that I need to use the StoreFront API, and more precisely the checkout part, and that the cart should be managed by myself, inside my app.

I have checked the following url : https://help.shopify.com/en/api/storefront-api/guides/checkout-guide

It gives me some good hint on the checkout process, but I am still missing some guidelines :

- When I create a checkout, which field is mandatory ? Which one is optional ?

- I seems that i cannot use Graphiql Explorer for mutation, as I don't find any explanation on the "checkoutCreate". Is there a more precise documentation that gives me exactly which field is being used to create/modify/complete the checkout ?

 

I do have some more questions regarding the cart in my Shopify Store webpage.

When i go to my website without being logged in :

- If I add some products, some kind of a "generic cart" is created

-> where is this cart stored ? In the cookies of my website ?

-> Is there a way to retrieve this information ? which field should be retrieve ?

 

When i go to my website as an identified user  :

- If I add some products, a cart is created is also created. Same questions as before

-> where is this cart stored ? In the cookies of my website ?

-> Is there a way to retrieve this information ? which field should be retrieve ?

 

Regards,

0 Likes
Highlighted
Tourist
13 0 3

Hi Dave,

 

Could you give me a hand on this one ?

 

I think i am not the only one facing this issue :

A customer is logged in but did not go to checkout, and so the cart is not saved with the user.

 

Regards

0 Likes