How can I create an equal search query for tags without using includes?

josu24
Shopify Partner
11 0 0

Hello!
How can I specify a query for tags that EQUALS and not INCLUDES? 

 

If style is

 

 

stylen_ace jacket

 

 

This query will return products that have that tag but also products that have

 

 

stylen_ace jacket patterned

 

 

 

Skärmavbild 2023-12-21 kl. 09.23.23.png

 

I see that the query in Shopify Admin works the same way, using includes logic:

Skärmavbild 2023-12-21 kl. 09.27.31.png

Replies 5 (5)

Rishihuptech
Shopify Partner
429 73 76

Hi @josu24 
Add the below code and check if this fulfills the functionality

{% for tags in product.tags %}
      {% if tags contains 'stylen_' %}
<!-- content-->
          {% break %}
      {% endif %}
    {% endfor %}
If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
josu24
Shopify Partner
11 0 0

No in my case there is never more than one "stylen_" tag, should break it anyway though.
The issue is with the query 

tag:"{{ style }}"

 

Rishihuptech
Shopify Partner
429 73 76

Hi @josu24 
What exactly do you want the functionality to work?
Like what you are trying to achieve
Another thing is if there is only one stylen_ace tag then you can simply add the below code

{% for tags in product.tags %}
      {% if tags == 'stylen_ace' %}
<!-- content-->
        {% break %}
      {% endif %}
    {% endfor %}
If you found this response helpful, please do like and accept the solution. Thanks!
Need support with Customizing your Shopify store?
Feel free to contact me at info@huptechweb.com or Visit our website Huptech Web.
Instant Shortcode Builder: Integrate customizable UI features anywhere in your store - No coding knowledge required
josu24
Shopify Partner
11 0 0

Query all products that have the exact same "stylen_" tag as the product added:

Skärmavbild 2023-12-21 kl. 12.37.58.png

See https://community.shopify.com/c/shopify-flow-app/adding-products-to-a-list-of-products-metafield/m-p... if you want more context! 🙂

paul_n
Shopify Staff
920 127 221

That query will always return partial matches like that and I don't think there is a way to force it to be exact. That said, you might be able to use tags_not...something like:

tags:"{{ the_tag }}" AND tags_not:"{{ the_tag }} "

Note the space after the second one. I think that should limit searches that match something else, assuming they are always separated by a space.

Paul_N | Flow Product Manager @ Shopify
- Finding Flow useful? Leave us a review
- Need Flow help? Check out our help docs.
- Building for Flow? Check out Flow's dev docs.