Change sale badge to show percent off

Tourist
11 0 1

Is this possible? My badge currently just states 'SALE' but I'd like to change it to say "--% Off" - the percentage calculated from the sale price vs original price. 

 

1 Like
Shopify Partner
385 0 49

Hello Paddy,

Fantastic question.

Let me try to explain this.

Yes this is absolute possible. Depending on the theme the code placement would vary. I'm giving you an option how the calculation could be done, this would give you a percentage for example 20%:

{{ product.price | times: 100 | divided_by: product.compare_at_price_max | ceil | append: '%' }}

For sanity sake your case may vary, and depending on if you have different variant prices the case may also make it harder to do accurately. You could always show something like "Up to 50% Off" if your variant prices differ.

Let me know if this is sufficient or if you need extra guidance.

Kasimir

"Good design is good business"
0 Likes
Tourist
11 0 1

Thanks a lot for your help Kasimir. Good to hear that this is possible. The "Up to 50% Off" sounds like a good solution to the variant issue. I need a bit of help with placement though. I've looked but I can't figure out where your code should be placed. 

0 Likes
Shopify Partner
385 0 49

Hello Paddy,

It differs on what theme you are working with.

Can you tell me what theme you working with? And I can point you to the right direction.

Kasimir

"Good design is good business"
0 Likes
Tourist
11 0 1

Thanks Kasimir. 

I'm on the Classic theme

0 Likes
Shopify Partner
385 0 49

Hello Paddy,

Thanks for that.

I'm unable to find the theme called Classic in the theme store.

Kasimir

"Good design is good business"
0 Likes
Tourist
11 0 1

Shopify no longer offer it as a theme unfortunately.

 

0 Likes
Shopify Partner
385 0 49

Hello Paddy,

Send me an email to kasimir(  at )johd.in 

Kasimir

"Good design is good business"
0 Likes
Tourist
11 0 1

Edit. email sent

0 Likes
Tourist
11 0 1

Thank you Kasimir. Fantastic help and you clearly have a very good knowledge of Shopify and coding. Not only did you implement my required change but you also corrected a slightly related Shopify error on my theme. Would be happy to work with you anytime. Highly recommended. 

0 Likes