I want replace badge sale with percentage on shopify

Highlighted
New Member
4 0 0

Hi, I have the Envy theme and I want to replace the sales badge with the percentage, I tried with the code I find in the forum community but it has always had 0 as a percentage, how can I solve?

Thank you

0 Likes
Highlighted
Shopify Partner
1158 233 300

Hello,

Use this one

{% if product.compare_at_price_max > product.price %}Save {{ product.compare_at_price_max | minus: product.price | times: 100.0 | divided_by: product.compare_at_price_max | money_without_currency | times: 100 | remove: '.0'}}%{% endif %}


Thanks 

Want to modify or custom changes on store hire me.
My Email: guleriathakur43@gmail.com
Skype: navrocks1
If helpful then please Like and Accept Solution.
If you are happy and want to donate small Click here (Its my paypal)
0 Likes
Highlighted
New Member
4 0 0

Hello,

thanks for your answer, i tried the code but it doesn't give me the percentage, it just comes out empty.

This is the original code:

{% if liquidObject.available %}
    {% if liquidObject.compare_at_price_max > liquidObject.price and settings.sale_badge %}
      <div class="envy-badge sale-badge">{{ 'products.general.sale' | t }}</div>
    {% endif %}

 

if i try to put this: 

{{ current_variant.compare_at_price | minus: current_variant.price | times: 100.0 | divided_by: current_variant.compare_at_price | money_without_currency | times: 100 | remove: '.0'}}%

  it gives me always 0%

0 Likes
Highlighted
Shopify Partner
1158 233 300

I'm using same check screen-shot
save.PNG

Want to modify or custom changes on store hire me.
My Email: guleriathakur43@gmail.com
Skype: navrocks1
If helpful then please Like and Accept Solution.
If you are happy and want to donate small Click here (Its my paypal)
0 Likes
Highlighted
New Member
4 0 0

Here what is appear to me 

Schermata 2020-11-12 alle 11.36.20.png

0 Likes
Highlighted
New Member
4 0 0

This the the entire original code, can you help me?

 {% if liquidObject.available %}
    {% if liquidObject.compare_at_price_max > liquidObject.price and settings.sale_badge %}
      <div class="envy-badge sale-badge">{{ 'products.general.sale' | t }}</div>
    {% endif %}
  {% elsif settings.sold_out_badge %}
    <div class="envy-badge sold-out-badge">{{ 'products.product.sold_out' | t }}</div>
  {% endif %}
0 Likes