How to compare the prices of my products in percentage on Refresh Theme?

Hello,

I have a problem and i can’t find a way to solve it alone. If someone helps me i’ll be very happy.

So i have a products in my shop but i want for the customers to see what is the discount of the products but in percentage. I’am using the “Refresh Theme” !

I’am waiting for a professional solution about my problem.

Michael Marinov, YourChoiceMM.

1 Like

@MMichaelMarinov - Hello Michael, this will need some code editing to put % discount on your product page, does your products have various variants or single variant?

Various variants. @suyash1

1 Like

@MMichaelMarinov - ok then you will need someone who is really good with ajax coding because price and discount will change as per the variant change if you have different prices.

@MMichaelMarinov

You want to display like this, percentage Badges,

Yes :astonished_face: @devtalk

1 Like

@MMichaelMarinov

Here is a link,
in this link it has many of code you can try out,
https://community.shopify.com/c/shopify-design/tutorial-displaying-saved-amount-percentage-on-the-sale-badge/td-p/923669

let me, know if you want i can help you to build the solution for you,

Thank you.

I saw this article. It’s for different Themes. @devtalk

1 Like

@MMichaelMarinov
{% assign price = product.selected_or_first_available_variant.price %}
{% assign compare_at_price = product.selected_or_first_available_variant.compare_at_price %}
{% assign discount_percentage = compare_at_price
| minus: price
| times: 100.0
| divided_by: compare_at_price
%}
-{{ discount_percentage | round: 0 }}% off

Add this code at the place of the Sale badges.

You can Check it’s working Solution.

thank you.

1 Like

Where to you place the code ? Thanks