Display percentage off instead of sale badge [ Venture Theme ]

alexandris
Shopify Partner
14 2 1

Hello everybody !

I wanted to change my "sale" badge into "percentage" badge on my shopify store using this tutorial.

The problem is that this tutorial  is not working on venture theme, or it simply has a calculation error.

 

10-00-9pqxe-lvk89.jpg

I want to show you how to modify "sale" badge into "percentage" badge on venture teme:

 

1. From your admin, go to ‘Online Store > Actions > Edit Code’.

2. In your ‘Snippets’ folder, select ‘product-card.liquid’ file.

 

 

3. In this file, search for ‘products.product.on_sale’.

 

If you are using a Mac, press Command + F to search or on Windows, press Control + F. 

10-11-947f8-zni2w.jpg 

 

 

4. Replace this:

 

{{ 'products.product.on_sale' | t }}

With:

 

{{ product.compare_at_price | minus: product.price | times: 100 | divided_by: product.compare_at_price | money_without_currency | replace: '0,', ''| append: "% OFF"}} 

 

 

 

 

0 Likes
SWSolutions
Trailblazer
193 25 47

Try to using this code-

 

{{ 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'}}% OFF

 

Thanks.

For Design, Development and custom changes Hire Me.
If your problem solved then Like & Accept this Solution.
Email ID: silencewebsolutions@gmail.com
alexandris
Shopify Partner
14 2 1

When i use your code, it shows to me 0%


@SWSolutions wrote:

Try to using this code-

 

{{ 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'}}% OFF

 

Thanks.


 

0 Likes
SWSolutions
Trailblazer
193 25 47

Hi,

Are you add the compare price in your products?

See the video- https://youtu.be/jZJrCfpZgLo

Thanks.

For Design, Development and custom changes Hire Me.
If your problem solved then Like & Accept this Solution.
Email ID: silencewebsolutions@gmail.com
0 Likes
alexandris
Shopify Partner
14 2 1

I already said that this method is not working for me. Did you read my post?

It shows me 0%

 

This code helped me:

 

{{ product.compare_at_price | minus: product.price | times: 100 | divided_by: product.compare_at_price | money_without_currency | replace: '0,', ''| append: "% OFF"}} 
0 Likes
a_longhurst
New Member
3 0 0

I am trying to change the sale badge to reflect the amount of money saved. So the product price minus the compare at price. I am currently moving from the supply theme to venture and the supply theme shows a badge like 'Save £8'. I want to carry this across. Can someone help?

 

Many thanks

0 Likes
EXOCYCLES
New Member
1 0 0

hi everyone,

 

I have the debut theme and would also like to include a little badge that says "xx % off" instead of sale.

 

Please could you assist? 

 

Kind regards,

Shakira

0 Likes
gomonke
Shopify Partner
2 0 0

This works for me

 

{% assign result = product.price | times: 1.0 | divided_by: product.compare_at_price%}
{% assign result = 1 | minus: result | times: 100 | ceil %}

0 Likes
erboristeria-do
New Member
8 0 0

@alexandris wrote:

I already said that this method is not working for me. Did you read my post?

It shows me 0%

 

This code helped me:

 

{{ product.compare_at_price | minus: product.price | times: 100 | divided_by: product.compare_at_price | money_without_currency | replace: '0,', ''| append: "% OFF"}} 


Hi, thank you for your help.

There is an issue when percentage of discount is under 10%

For example you don't see -5% discount but -05% discount.

How to remove 0 in front of first number?

0 Likes
plumastudio
New Member
1 0 0

I use this code

{{ product.price | times: 100 | divided_by: product.compare_at_price | divided_by: 10 | remove: '.0' | append: '%' }}  
0 Likes