How to exclude/ hide a specific product category from general Product_card edit

hi all, I am trying to add an image from my asset folder to my product_card. But will like to exclude a particular category. I used this code

which added the image to all my products on the collection page. However, I will like to exclude a particular category that does not need this image.

I tried to add {% unless product.tags contains ‘brass’ %} but it did not work. Any help on how to fix this problem? thanks

@dorot44 So your code more or less looks like the following?

{% unless product.tags contains 'brass' %}
 
{% endif %}

Depending on theme it may actually be current_product or some other alias variable the theme uses in collection templates when looping over products, or it uses ajax, or does not use product_card .

There’s also being sure products do not actually contain that string not just the word , so brassware would also match as a type of false negative.

Or target the collection directly

{% if collection.handle != 'brass' %}
 
{% endif %}
{% unless collection.handle contains 'brass' %}
 
{% endunless %}

thanks for the response. It didn’t seem to work when I targeted the collection only. I’m using the debut theme

“seem”, be specific what steps did you take, how did you modify the provided code to fit your use case, do you have an example url, etc.

the collection is called Brass jewellery collection. So I changed the name as: (see below) to exclude the collection.

{% unless collection.handle contains ‘brass jewellery collection’ %}

{% endunless %}

I put this code right above: {% include ‘product-price-listing’, product: product, show_vendor: show_vendor %} as this is where I want the image to show in the snippet: product.card.grid.liquid.

But it did not exclude the brass jewellery collection. The image showed up under all products in the collection page.

While that’s a good attempt there’s a catch with handles in that they get “handleized” which is the name as you see it in that collections url

so brass jewellery collection becomes brass-jewellery-collection with dashes(-) and thus may not be a match when using the contains operator as you want to be less specific.

Using just contains would be more like {% unless collection.handle contains ‘brass’ %}

A more specific working match would be

{% unless collection.handle == 'brass -jewellery-collection' %}

{% endunless %}