Hello!
I found this information online: "Add a 'Continue shopping' link to your cart", specifically the last component of the tutorial for "a link that goes to the last collection viewed".
I would like to implement this, however NOT as part of a "continue shopping" button; nothing to do with my cart. I simply want to make a button or link in my Product Template that says "go back to collection" etc.
For your convenience, the code in the linked example is as follows:
<a
id="continue-shopping"
href=""
title="Continue shopping"
>Continue shopping</a
>
JS to go into the Theme.Liquid body:
<script>
if(Storage !== undefined) {
var defaultLink = "/collections/all";
{% if template contains 'collection' %}
sessionStorage.collection = "{{ collection.url }}";
{% endif %}
{% if template contains 'cart' %}
if( !sessionStorage.collection ) {
sessionStorage.collection = defaultLink;
}
document.getElementById("continue-shopping").href = sessionStorage.collection;
{% endif %}
}
</script>
Will the above script need to be amended and if so, could someone please provide me with adjusted code to suit my needs?
Thanking you in advance.
Solved! Go to the solution
This is an accepted solution.
Hi,
You can refer this article https://community.shopify.com/c/Shopify-Design/How-to-add-quot-Back-to-Collection-quot-button-to-the...
User | Count |
---|---|
25 | |
20 | |
17 | |
16 | |
15 |