Hello,
I am working on a fully headless implementation using the Storefront API. Some of my products are subscription products, so I am using selling plans. If someone can, please help me understand the following…
-
What is the difference between Cart (https://shopify.dev/api/storefront/reference/cart) and Checkout (https://shopify.dev/api/storefront/reference/checkouts)?
-
In the beginning I started working with checkouts but then I realized that the cart’s cartLinesAdd mutation has the ability to assign a sellingPlan. Is it correct to assume that checkouts do not support selling plans at all?
-
I ended up rebuilding my whole cart management to use Cart instead of Checkouts, but now I am realizing that the cart’s checkoutUrl works differently than checkout’s webUrl? Does a cart have an associated checkout or are these two completely different things?
-
In this fully headless scenario, is there any way to guarantee that the user will only need to log in once? In some of my tests, when accessing the checkoutUrl or the webUrl (before) I was redirected to /account/login. I’ve also tried using cartBuyerIdentityUpdate to associate my user with the cart via the customerAccessToken but that doesn’t seem to accomplish anything?
Thank you!
3 Likes
1. What is the difference between Cart (https://shopify.dev/api/storefront/reference/cart) and Checkout (https://shopify.dev/api/storefront/reference/checkouts)?
The Cart API has recently been added and the intention seems to be to eventually replace the Checkout API so they’re mutually exclusive in a way meaning you either use one or the other in most cases. If your store sells subscriptions then the Cart API is your only option as the Checkout API, as you’ve already found out, does not support them and I doubt it ever will. The Cart API was specifically introduced after Shopify started support subscriptions (a.k.a. selling plans) in the core. In terms of features they’re comparable with only two missing features in the Cart API - disassociating customer from the cart doesn’t seem to be possible and there also does not seem to be a way to calculate a shipping rate via the Cart API. On the other hand though, the Checkout API is missing subscriptions so you have to make a decision.
2. In the beginning I started working with checkouts but then I realized that the cart’s cartLinesAdd mutation has the ability to assign a sellingPlan. Is it correct to assume that checkouts do not support selling plans at all?
That’s exactly right.
3. I ended up rebuilding my whole cart management to use Cart instead of Checkouts, but now I am realizing that the cart’s checkoutUrl works differently than checkout’s webUrl? Does a cart have an associated checkout or are these two completely different things?
What do you mean differently? It surely directs the user to a different URL and I also noticed one more difference where the checkout page does not show a “Return to cart” link when you follow a link provided in the Cart API response which really is a blessing - we had to hack together a custom “headless template” to handle this button’s action properly and redirect to our custom storefront before. That extra effort is almost unnecessary at this point.
4. In this fully headless scenario, is there any way to guarantee that the user will only need to log in once? In some of my tests, when accessing the checkoutUrl or the webUrl (before) I was redirected to /account/login. I’ve also tried using cartBuyerIdentityUpdate to associate my user with the cart via the customerAccessToken but that doesn’t seem to accomplish anything?
Did you put your store behind a password by any chance? That might be the reason. I have not noticed this before. To your question about federated login - no that’s not supported unless you’re a Shopify Plus user (enterprise tier, super expensive) - but in case you are, go take a look at multipass API - https://shopify.dev/api/multipass
1 Like
Hello @mareksuscak , circling back to this regarding #4 from the original post. I have disabled the password protection of the shop and I am still required to log in a second time in shopify, when I am redirected to webUrl. Can you please help me understand the steps you followed to ensure your users don’t need to log in twice?
I am using cartBuyerIdentityUpdate with buyerIdentity parameters: email, phone, customerAccessToken and countryCode. Are you also using that in the same way?
Thank you!
2 Likes