Last active
March 15, 2023 00:10
-
-
Save garrettmac/7a536ec1dd40c69bac9dffbb715902ac to your computer and use it in GitHub Desktop.
Shopify Filter Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shop: | |
<!-- https://sunnyradios.com/collections/types?q=Antennas --> | |
<ul> | |
{% for product_type in shop.types %} | |
{% assign type_handle = product_type | handleize %} | |
{% assign type_collection = collections[type_handle] %} | |
<li class="{% if product.type == product_type %}current{% endif %}"> | |
{% if type_collection == empty %}{{ product_type | link_to_type }} | |
{% else %}{{ type_collection.title | link_to: type_collection.url }} | |
{% endif %} | |
</li> | |
{% endfor %} | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% if collection.url != blank %} | |
<h4>Shop by vendor:</h4> | |
<ul> | |
{% for product_vendor in collection.all_vendors %} | |
<li> | |
{% if current_tags contains product_vendor %} | |
<a class="active" href="{{ collection.url }}">{{ product_vendor }}</a> | |
{% else %} | |
<a href="{{ collection.url }}/{{ product_vendor | handle }}">{{ product_vendor }}</a> | |
{% endif %} | |
</li> | |
{% endfor %} | |
</ul> | |
{% endif %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
/* Product Tag Filters - Good for any number of filters on any type of collection page. */ | |
Shopify.queryParams = {}; | |
if (location.search.length) { | |
for (var aKeyValue, i = 0, aCouples = location.search.substr(1).split('&'); i < aCouples.length; i++) { | |
aKeyValue = aCouples[i].split('='); | |
if (aKeyValue.length > 1) { | |
Shopify.queryParams[decodeURIComponent(aKeyValue[0])] = decodeURIComponent(aKeyValue[1]); | |
} | |
} | |
} | |
var collFilters = jQuery('.coll-filter'); | |
collFilters.change(function() { | |
var newTags = []; | |
var newURL = ''; | |
collFilters.each(function() { | |
if (jQuery(this).val()) { | |
newTags.push(jQuery(this).val()); | |
} | |
}); | |
if (newTags.length) { | |
Shopify.queryParams.constraint = newTags.join('+'); | |
} | |
else { | |
delete Shopify.queryParams.constraint; | |
} | |
location.search = jQuery.param(Shopify.queryParams); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i want to add the color and size variant option .