Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi everyone,
I'm in a strange situation and I would like to see your opinion about it.
I am planning to launch a Shopify store in the near future, but with a different kind of setup. The storefront is a custom website built using HTML5, CSS3, and some JavaScript, and the backend is Shopify. Basically, all my products and orders will be handled from Shopify. I will pull the product data and collections into my website and I am in a situation when I want to choose the best option in terms of managing the cart.
- Manage the cart in Shopify and add products to the cart using the Cart API.
- Manage the cart in my custom website and interact with Shopify only when an order is placed (integration with the Order API to create orders based on my custom cart with Shopify products).
I have questions for you:
1. Is it possible to have a separate storefront and however manage the cart in Shopify (somehow in the background)? If you're positive about this, how's this doable? If it will work, I'm afraid about the Shopify API limits, considering the number of carts that will be created.
2. Is it possible to have a separate storefront and use Draft Order API for managing a fictive cart? Once the order is completed, I'll just transform that order from a draft one to complete order.
3. What happens with the draft orders that are closed? Will they still be visible in Shopify's backend?
4. Is it a better way to handle this only using the Order API, once the checkout is completed?
Looking forward to hearing back from you.
If you want to build a separate/headless storefront you can manage a cart using a checkout in the Storefront API. Though for performance reasons you should probably store the cart locally and create the checkout when the customer is ready to checkout. I wouldn't try to do this with the Admin API unless you have a really specific use case that requires it.
If you just want custom HTML, CSS, and Javascript, your life would be a lot easier if you create a custom Liquid theme.
Thank you for replying, @c10s.
Why do you think trying with the Admin API is not a good approach? What bottlenecks may occur?
It really depends on what you're trying to do:
Trying to do it with just the Admin API may be possible but would be much more involved approach with its own limitations (eg. don't think you can authenticate customers), so unless there is good reason to, I would say trying to do it with only the Admin API is a bad approach.
My typical setup these days for headless shops is a React app that uses the Storefront API to handle the main customer shopping experience (show products, add to cart, forward to checkout). Then a separate private API that uses the Shopify Admin API I can hit if I need to more backend updates that aren't fit for the Storefront API (update a customer's metafields for example).