{% if collection.handle == 'gafas-de-sol' and collection.tags contains '' %} not works. I need help

YerayLg
Tourist
9 0 0

Hello, I'm trying to make that if you are on a page with no tag, one thing happens but if there is any other tag, other thing happens. I'm testing it with the following code and I think the error is in [collection.tags contains '' "] but I don't know what to do.

{% if collection.handle == 'gafas-de-sol' and collection.tags contains '' %}

something

{%else%}

something
{% endif %}
Thanks

0 Likes
Pallavi
Shopify Expert
2235 369 484

Hello @YerayLg 

use like this .

{%- for product in collection.products -%}
    {%- if product.tags contains 'bundle-builder-dummy-legacy' -%}
        ** do nothing **
    {%- else -%}
        ** print out product **
    {%- endif -%}
{%- endfor -%}

 

Want to modify or develop new app, Hire us.
If helpful then please Like and Accept Solution .
Email: support@zestard.com
Shopify Apps URL :- https://apps.shopify.com/partners/zestard-technologies
Custom Modifications Into Shopify Theme | Shopify Private App | SEO & Digital Marketing
0 Likes
YerayLg
Tourist
9 0 0

Ok, but I'm doing it with a <select> and I want that when you are on one page the <option> method is one thing and when you are on another page the option method is another.

I leave you the code

<select name="SortTags" id="SortTags" aria-describedby="a11y-refresh-page-message a11y-selection-message" >
<option value="/collections/{{ collection.handle }}">All</option>
{% for t in tags %}
{% assign tag = t | strip %}
{% if current_tags contains tag %}
<option value="{{ tag | handle }}" selected>{{ tag }}</option>
{% elsif collection.all_tags contains tag %}
{% if collection.handle == 'gafas-de-sol' and collection.tags contains '' %}

<option value="/collections/{{ collection.handle }} / {{ tag | handle }}">{{ tag }}</option>
{% endif %}
{% endif %}
{% endfor %}
</select>

0 Likes