Is it possible to add a badge under "Add to Cart" on select products based on a Label Tag?

Solved
Tourist
3 0 0

Hello!

I was wondering if it was possible to add custom badges to select products based on a tag? I already have trust badges in place (PayPal, Visa, etc) but I'd like to add another level of badges to only a few products that are Eco Friendly.

 

Is this possible and if so, what is the best way to set this up so I can easily turn it on or off for select future products? In a perfect world it would be awesome to just add a tag that would make it show up - but I'm definitely open to other suggestions!

Any input would be greatly appreciated, thank you so much!

0 Likes

Success.

Astronaut
1069 144 256

Yup, 100% possible. You would have to go into your product-template.liquid section (if this doesnt exist it's probably just product.liquid in the templates folder) and find where your add to cart button is, then use a conditional statement to check the product's tags and if it has the tag, display the badge. So say you tagged the product "ecofriendly" it would be something like:

 

<button class="add-to-cart">Add To Cart</button>
{% if product.tags contains "ecofriendly" %}
<img src="/path-to-your-badge.jpg">
{% endif %}
If you'd like to make any edits to your store, please send me a personal message and we can discuss what you'd like to accomplish :D
1 Like
Tourist
3 0 0

Thank you so much Ninthony - this was EXACTLY what I've been needing!

0 Likes