Shopify / js-buy-sdk

The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website. It is based on Shopify's API and provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.

Home Page:https://shopify.github.io/js-buy-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cart API vs. Checkout API

zmonteca opened this issue · comments

Hello all...

So we have two apps / systems trying to add and update our headless Shopify "cart"...

One part of the app uses the Checkout API and Checkout mutations like checkoutCreate & checkoutLineItemsAdd to create and add to our "cart"

In the other part of the system (adding selling plan subscriptions to our "cart"), we're working with Cart API and Cart mutations like cartCreate & cartLinesAdd to create and add to our "cart".

With the Checkout API, we have things like the checkoutId that we're working with to locate existing sessions and put new "cart" items in the right place.

With the Cart API, we have things like the cartId that we're working with to locate existing sessions and put new "cart" items in the right place.

It seems absolutely incomprehensible that the architects of these two systems created such walled gardens between these two layers that you can't put Cart API lines into a "cart" with the checkoutId in the Checkout API. And vice versa, you can't put Checkout API lineItems into the same "cart" as other Cart API items.

Am I missing something really obvious or big here or is there a reason for keeping these two implementations–Cart & Checkout–completely separate and isolated so they can NOT work together?

They can not work together; those are the different levels of "payment." The cart API is the first "step" of the checkout process. The Checkout API is the second one.

Use the cart API if you want to interact with your Shop store (there is a Cookie called cart that can be synchronized with a cookie on your third-party site). https://github.com/Shopify/js-buy-sdk doesn't support it from the box, but you can always create GRAPHQL Queries.

Use Checkout API if you don't need the first step.

Can you please clarify Use the cart API if you want to interact with your Shop store? When would one use the cart API as opposed to just the checkout API?