How To Adding a Percentage OFF tag to the Simple theme?

New Member
3 0 0

Hi All, I hope someone can help me out here. I want to add a Percentage OFF tag to my store (Simple Theme), eg "25% off" or something similar.I've seen a few requests before ,and referred to this post but didn't work. There are other bits of code out there for other themes that may work but nothing saying where to put it that matches my theme.
Thank you in advance for any help you all can give.

 

0 Likes

You can add this code to your Product.liquid or Collection liquid file

<span class="lh-onsale">
-{{ variant.compare_at_price | minus: variant.price | times: 100 | divided_by: variant.compare_at_price}}% OFF
</span>

 

LayoutHub - Build your E-commerce store by the easiest way
0 Likes
New Member
3 0 0

Thank you for your advice.I tried but it didn't work.Thank you very much.

0 Likes

So sorry, let's update

{% if product.selected_or_first_available_variant.compare_at_price  > 0  %}
          <span class="lh-onsale">-{{ product.selected_or_first_available_variant.compare_at_price | minus: product.selected_or_first_available_variant.price | times: 100 | divided_by: product.selected_or_first_available_variant.compare_at_price}}%</span>
          {% endif %}

It's working on my side https://prnt.sc/qeiky6

LayoutHub - Build your E-commerce store by the easiest way
0 Likes
New Member
3 0 0

微信图片编辑_20191225085649.jpg

Just like this style?Can anyone help me?Thank you first~

0 Likes