Create a shopping cart and add items to the cart for customer in Shopify

bluewave
Tourist
7 0 2

If you use the graphQL storefront api, treat the "checkout" as a cart, just assume it is the same until the checkout received the customer data.

If you store the checkout ID you can even retrieve it down the line to continue a user session (localstore, session store... or DB) that is the simplest way. The Storefront API doesn't have a "cart" mutation, only checkout.

 

Cheers

0 Likes
lockybanna123
New Member
3 0 0

Hello

I am also a React native developer but I am stuck in Shopify Ajax cart api So can you please tell me its base url(Shopify Ajax cart api), I am not able to understand which base url I should use.   Thanks  

0 Likes
c10s
Shopify Partner
39 7 6

@lockybanna123 The AJAX cart api is for use in themes. You can use the Storefront API for what you're trying to do.

Storefront API is a post request to https://{shop}.myshopify.com/api/2021-04/graphql.json.

As the comment above mentioned you can consider a 'checkout' the same as a cart. You can either manage your cart state locally then create a checkout once a customer is ready to check out, or run a checkout mutation on every relevant action (add item to cart, remove item from cart, etc.)

Shopify has the js-buy-sdk if you don't want to use GraphQL directly.

0 Likes