Storefront API Checkout URL not working #197
-
Hi everyone, I'm the creator and core maintainer for the Skeleton UI library 👋 I'm in the process of building a new storefront that will sell premium assets for Skeleton, such as website templates. I've been very much enjoying Shopify and it's features, and we've managed to implement the majority of our store using the Storefront API. I've been able to query collections, products, create a cart, etc. Unfortunately I've been hitting a wall when it comes to the Reference: https://shopify.dev/docs/api/storefront/2023-04/mutations/cartCreate
This works and does provide a checkout URL as expected: Unfortunately no matter how many times I try this, the URL provided does not work as expected. Instead we're always rerouted to the homepage of our Shopify hosted template store. I've recorded a quick video showing this: Kapture_2023-07-05_at_11.03.59.mp4You'll note I'm logging the
It feels like it's trying to redirect to a particular route that doesn't exist or is not accessible, so we're getting dumped back on the homepage. However if I try to go through the checkout process on the hosted site, I do end up on the checkout page as expected as shown here: Kapture.2023-07-05.at.14.55.15.mp4The only difference I've noted is the structure of the URLs differ:
Any ideas what I'm doing wrong here? Is there maybe a store permission or flag I need to toggle in our admin to enable this to work? We're currently using the Basic plan if that matters. Thanks for any help you can provide! |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 23 replies
-
Hey @johncraigcole I apologize for pinging you directly on this one, but you seem like one of the few active folks in threads here. I've reached out to the Shopify live chat support, the forums, the Shopify Dev Discord, and now here. We've been roadblocked on this issue for a couple days - if you can't help us directly is there any way you could send us in the right direction for where we might be able to get some assistance on this issue? We're on a tight deadline to get this store up and running, so again I apologize for being impatient. Thanks for any help you can provide. If I can provide any additional information to help please just let me know. |
Beta Was this translation helpful? Give feedback.
-
hello,my local shopify hygroden project can use "npm run dev" to run,but it has a problem "Failed to fetch Hydrogen changelog " |
Beta Was this translation helpful? Give feedback.
-
@johncraigcole Apologies for DMing you on this thread, but I cant find anyone active that might be able to help with an similar issue. I'm using the hydrogen-react package, I'm managing to update my cart with the perfectly fine, and I can see lineItems being added to my cart correctly. However it seems the checkoutUrl is wrong, redirecting is not working as expected when using the The checkoutUrl is: http://storedomain.com/cart/c/(token) Looking at other examples of using hydrogen-react I'd expect my checkout url to be something similar to: https://storedomain.myshopify.com/checkouts/cn/(token) Has anyone experienced this before? For reference, I am moving away from using the js-buy-sdk package as it does not support subscriptions (checkout api versus storefront api) - however in my live app using this package, the checkout url is https://storedomain.myshopify.com/checkouts/cn/(token) For reference I am giving the storeDomain as 'storedomain.myshopify.com'. |
Beta Was this translation helpful? Give feedback.
-
@johncraigcole sorry for also asking questions here, but you seem to really understand what you are doing. We are currently migrating from the checkout API to the cart API and are facing some issues with the checkoutUrl of the cart API. With the checkout API we always got back an URL in the following format: We now face the issue that with the old checkout URL the use got send to the checkout page of Shopify. However, with the URL from the cart API, the user is of course only send to our website that does not have the handling for cart endpoint. I tried changing the URL ton https://.myshopify.com/cart/c/?key=, however that just redirect to our again. How can we achieve the same behavior that we had with the URL from the checkout API also with the URL from the cart API? |
Beta Was this translation helpful? Give feedback.
@endigo9740 your second example might be because the cart is empty?
Checkout can't be started without any line items, so it redirects to the online store cart page. In a custom storefront build on Shopify, typically a developer would add a JS client side redirect to
theme.liquid
which redirects traffic back to the custom storefront. The redirect piece is documented here. While the docs are for Hydrogen and Oxygen, it's applicable to any custom storefront with a Shopify hosted checkout.