Exclude if product vendor is __ and product tags contain__

I’m trying to add 2 conditions on an %if tag on product-template.liquid code. Screenshot attached of what the code currently looks like.

It’s working for the first condition (vendor) but it’s not filtering out the second condition (product tags). Please let me know what I’m doing wrong!

code.JPG

Hello @Emma1903 ,

Greetings from the Store Watchers Support Team! Happy to help you today.

Product.tags value type is array not string that’s why it is not working. You have to use code like :

{% if product.vendor == 'Jamie Joseph' %}
{% unless product.tags contains 'RINGS' %}

ADD PARAGRAPH YOU WANT TO ADD HERE

{% endunless %}
{% endif %}

Note :

  • An array is a collection of a strings and A string is a simple text. Product.tags have multiple strings in it that is why the condition does not match.
  • Contains checks the case of string(case-sensitive)

Let me know if require further assistance!

Regards,

Store Watchers Support Team

Thank you so much! This is very helpful and makes sense. Where I’m stuck, is that I don’t want to exclude RINGS. I want to exclude all other product types (example: PENDANTS, NECKLACES, EARRINGS). How would I use this code in order to target product vendor JAMIE JOSEPH and RINGS?

Hello @Emma1903 ,

Please use below updated code to do it :

{% if product.vendor == 'JAMIE JOSEPH' and  product.tags contains 'RINGS' %}

ADD PARAGRAPH YOU WANT TO ADD HERE

{% endif %}