How can I display sale percentage in Dawn theme's sale badge?

I want the percentage to be shawn instead of text for the sales badge next to the price

1 Like

Hi @DaandeLeur

Go to Online Store > Clic the 3dots > Edit default theme Content >

When you enter choose Products.

And Find the on Sale.

Change and Save.

Result:

Please don’t forget to Like and Mark Solution to the post that helped you. Thanks!

Hi @DaandeLeur ,

Please refer to the code below to implement it in the card-product.liquid file. The file name may vary depending on the theme, but for reference, we’re using the DAWN theme here.

{%- assign difference = card_product.compare_at_price | minus: card_product.price -%}
{%- assign float_difference = difference | times: 1.0 -%}
{%- assign discount_fraction = float_difference | divided_by: card_product.compare_at_price -%}
{%- assign discount_percentage = discount_fraction | times: 100 | round -%}
{{- discount_percentage }}

For detailed implementation kindly refer the below video to implement the same.

Hope this will helps…