Where is the documentation on how to add items to cart with GraphQL's mutation or with REST?

Solved
MayneWeb
Tourist
14 0 1

Iv'e searched high and low on answers how to use add items to Cart. I'm building a headless storefront (challenging, I know), and I need to understand how the items are being added to Cart.

 

I've look here and see no mentioning of "Cart". My backend for this setup is using the Ruby gem.

 

Based on how I see carts work,  a customer, authenticated or not, can add something to cart, they can refresh their browser and it's still there so something unique is happening and I see no documentation on how to "add to cart".

Posts/replies by @MirMayne
Accepted Solution (1)

Accepted Solutions
PixelSplash
Shopify Partner
38 8 5

This is an accepted solution.

Hi @MayneWeb 

I don't know if this is the exact solution. I'm guessing Shopify manages Cart by storing the information about products in browser cookies and then creates checkout at the backend once the user proceeds for checkout. You can do similarily, here is the doc for storefront checkout API https://help.shopify.com/en/api/storefront-api/guides/checkout-guide#creating-the-checkout 

View solution in original post

Replies 2 (2)
PixelSplash
Shopify Partner
38 8 5

This is an accepted solution.

Hi @MayneWeb 

I don't know if this is the exact solution. I'm guessing Shopify manages Cart by storing the information about products in browser cookies and then creates checkout at the backend once the user proceeds for checkout. You can do similarily, here is the doc for storefront checkout API https://help.shopify.com/en/api/storefront-api/guides/checkout-guide#creating-the-checkout 

Benjaminlotan
New Member
2 0 0

So it seems like you are suggesting that a headless store should maintain and manage their own cart, and only rely on shopify when the user is going to "checkout" and pay... am I clear on that? 

it seems @MayneWeb is trying to implement using the shopify native cart. (only product pages are headless, and add to cart ideally sends them to the shopify hosted cart).