4
votes

I'm currently using shopify's theme mr. parker, and it has a filtering by tags snippet. I'm trying to re-purpose this filter collections by tags snippet to instead filter by the product size variant. So how it currently works is that the snippet will look at the product's tags and will the filter tags options from the themes collection admin menu and show it as a filter drop down on the collections page. It works great for tags, but now I want it to filter by the product variant's size instead.

{% if settings.sort-dropdown-a-check %}
<li class="clearfix filter">
{% assign tags = settings.sort_a  | replace: ' ,', ',' | replace: ', ', ',' | split: ','%}     
<p>{{ settings.sort-a }}</p>
<select class="styled-select coll-filter">
  <option value="">All</option>
  {% for tag in tags %}
  {% if current_tags contains tag %}
  <option value="{{ tag | handle }}" selected>{{ tag }}</option>
  {% elsif collection.all_tags contains tag %}
  <option value="{{ tag | handle }}">{{ tag }}</option>
  {% endif %}
  {% endfor %}
</select>
</li>
{% endif %}

Thanks, for looking.

2

2 Answers

0
votes

It looks like you're missing a piece to the puzzle. Judging by the Mr Parker demo store, it looks like this functionality is already built into the theme.

http://mr-parker.myshopify.com/collections/all

Please note that you can only filter collections by tags, not by product variants. So in order to filter the collections by size you will need to go through and tag all of your products with the necessary values (e.g. s, m, l etc).

As I haven't personally seen the theme code for Mr Parker I can't say for sure how it works, but it sounds like you will need to define these extra tag select menu either in the theme settings or maybe in a linklist.

0
votes

There is an app in the Power Tools Suite that can tag your products based on the variant titles, then you can simply filter by tag for your sizes. It even handles when you sell out of a size by removing the tag.