If cart is empty, the cart page will redirect to shop page in Shopify
You want to redirect the cart page to collection page or any pages when the cart page is empty otherwise shows the cart page. It’s simple.
- From your Shopify admin, go to Online Store > Themes.
- Find the theme you want to edit, and then click Actions > Edit code.
- In the Templates directory, click cart.liquid.
- Insert below code to the top of this file.123{% if cart.item_count == 0 %}<script>window.location.replace("/collections/all");</script>{% endif %}
You can replace “/collections/all” with any page URL.
Thank you for this!! For some reason our Shopify’s normal empty cart language doesn’t show, this is an improvement.
However, it takes a refresh to kick in after a customer empties their cart. Is there any way around this?