Show a banner only on product pages that are part of a collection?

Solved
Shopify Partner
5 1 1

Hi guys!

 

I'm trying to figure out the piece of code needed to show a banner.

That banner should only appear on products that are in a specific collection.

 

So basically:

 

if > collection.name = watches
show "These are our watches"
end

 

How do I do this?

0 Likes
Shopify Expert
165 40 66

@Oliur,

 

I would be happy to help you with this. What theme are you using? Could you please provide us with a link to your store so we can take a further look? 

 

I would recommend doing this based off of a product tag. So it would be something like: 

 

 

{% if product.tags contains == 'watches' %} 
  <img src="#" />
{% endif %} 

 

 

This condition will go at the top of your product-template.liquid file. Depending on your current setup, we might need to expand on that a little more. 

Did I provide you with a working solution? Give me an Approved Solution!

Likes are appreciated as well :)
1 Like

Success.

Shopify Partner
5 1 1

I actually ended up finding a solution for when a product is part of a specific collection.

 

{% for collection in product.collections %}
   {% if collection.title == 'YOUR COLLECTION NAME' %}
      <div class="collection-banner-container">
         <span class="collection-banner">YOUR TEXT</span>
      </div>
   {% endif %}
{% endfor %}

Regardless, thanks for your help @shayOwensby :)

1 Like
Shopify Partner
241 33 57

Thanks for posting solution @Oliur 

If helpful then please Like and Accept Solution
0 Likes