1
votes

I imagine someone has created this solution before and for the life of me I can't make sense of it.

I am using the following code to create a list of tags for my Men's T-Shirt department:

<ul>
   <li class="clearfix filter-type">Garment Type</li>
   {% assign tags = 'Short Sleeve, Long Sleeve, Polo, Crew %}
      {% for tag in tags %}
         {% if current_tags contains tag %}
            <li class="selected">{{ '-' | link_to_remove_tag: tag }} {{ tag }}</li>
         {% elsif collection.all_tags contains tag %}
            <li>{{ tag | link_to_add_tag: tag }}</li>
         {% endif %}
      {% endfor %}
</ul>

It works as expected, but what I am trying to accomplish is if one of the tags is selected, say "Short Sleeve", then the list should display ONLY "- Short Sleeve" and nothing else. Not allowing the customer to select any other tags from that group. Simply because, if something is tagged "Short Sleeve" it is not "Long Sleeve"

As it is working now, the customer could select "Short Sleeve" and then select "Long Sleeve" resulting in no results.

Any guidance would be greatly appreciated, thanks!

1

1 Answers

0
votes

The Filters page on the Shopify wiki states:

link_to_add_tag Links to products that have the given tag and any previously applied tags

link_to_tag Creates a link to the tag page

So, simply change link_to_add_tag to link_to_tag.

Also see: