Dawn 5.0.0 Code to change sale badge to a percentage on collection page

Hello,

I am looking for code to change the sale badge on the collection page to a percentage, I have removed the sale letters it is now a blank blob but no code I have found online seems to get the percentage to appear correctly.

Hi,
We have a solution for this task.

In this first you have to open the “product-card” snippet.
In the “product-card” snippet, you will find line no. 78

Theme code:-
{{ ‘products.product.on_sale’ | t }}

Instead of the code of the theme, you can add the code given by below :-
{% if product_card_product.compare_at_price_max > product_card_product.price %}{{ product_card_product.compare_at_price_max | minus: product_card_product.price | times: 100.0 | divided_by: product_card_product.compare_at_price_max | money_without_currency | times: 100 | remove: ‘.0’}}% off{% endif %}

After adding this code, Percentage will appear instead of sale badge in the collection.

Hello,

Thanks for this, I have been on the ‘Product Card’ Line 78 shows ‘loading=“lazy”’ - Please see screenshot of code below:

Hi,

In this first you have to open the “card-product” snippet.
In the “card-product” snippet, you will find line no. 98

Theme code:-
{{ ‘products.product.on_sale’ | t }}

Instead of the code of the theme, you can add the code given by below :-
{% if card_product.compare_at_price_max > card_product.price %}{{ card_product.compare_at_price_max | minus: card_product.price | times: 100.0 | divided_by: card_product.compare_at_price_max | money_without_currency | times: 100 | remove: ‘.0’}}% off{% endif %}

After adding this code, Percentage will appear instead of sale badge in the collection.

Hi, thanks for help
doesnt work. ther is not that theme code