Cart: Add a Continue Shopping link

To add a custom Continue Shopping link on your cart page or cart window, here are a few modifications you can try:

Option 1 - Link back to All Products

This version will send your shoppers back to the all products page. Open your Code Editor and edit templates/cart.liquid:

https://shopify.com/admin/themes/current?key=templates/cart.liquid&line=16

Around line 16, right below the <h3> heading, add the following code:

Code to add:

    <a class="{% if settings.cart_type contains 'page' %}btn btn--clear{% endif %} uppercase" href="/collections/all" title="Continue shopping">Continue shopping</a>

Example after adding code:

Save the file.

Page Cart Result:


Modal/Pop-up Cart Result:


Option 2 - Return to homepage

Use this code instead if you would like the Continue Shopping link to return to your homepage:

    <a class="{% if settings.cart_type contains 'page' %}btn btn--clear{% endif %} uppercase" href="/" title="Continue shopping">Continue shopping</a>

Follow the same steps as Option 1 but use this version of the code.


Option 3 - Return to last collection viewed (Page cart only)

Note: This version only works with the Page cart type. The link will be hidden if you switch to the Modal cart type. 

Step 1

Use this code instead if you would like the Continue Shopping link to return to the last viewed collection. Follow the same steps as Option 1 but use this version of the code:

    {% if settings.cart_type contains 'page' %}<a id="continue-shopping"class="btn btn--clear uppercase" title="Continue shopping">Continue shopping</a>{% endif %}

Step 2

This option also requires you to add the following code to your layout/theme.liquid file:

https://shopify.com/admin/themes/current?key=layout/theme.liquid&line=999

Code to paste at the very bottom of theme.liquid:

<!-- Code used for Continue Shopping link in cart -->
  <script>  
    if(Storage !== undefined) {

      {% if template contains 'collection' %}
      sessionStorage.collection = "{{ collection.url }}";
      {% endif %}

      if(sessionStorage.collection === undefined){
        sessionStorage.collection = "/collections/all";
      }

    {% if template contains 'cart' %}
      document.getElementById("continue-shopping").href = sessionStorage.collection;
    {% endif %}

    }

</script>
<!-- end -->

Save the file. 


Option 4 - Go back to previous page with Page cart type

With the page cart you can use this method to have a Continue Shopping button that returns you to the last page.

Step 1 - Add one line to cart.liquid

https://shopify.com/admin/themes/current?key=templates/cart.liquid&line=16

Around line 16, right below the <h3> heading, add the following code:

Code to add:

<a class="back btn btn--clear">Continue Shopping</a>

Save the file.

Step 2

This option also requires you to add the following code to your layout/theme.liquid file:

https://shopify.com/admin/themes/current?key=layout/theme.liquid&line=999

Code to paste at the very bottom of theme.liquid:

<!-- Code used for Continue Shopping link in cart -->
<script>
$(document).ready(function(){
	$('a.back').click(function(){
		parent.history.back();
		return false;
	});
});
</script>
<!-- end -->

Save the file.