How To Show % Discount On A Product - Dawn

Hey @Tara123 ,

Please follow the following steps:

  1. Go to your online store and select Themes from left panel

  2. Press 3 dots menu in center (on the left of Customize button) and then Edit Code

  3. Open the file price.liquid (you can search for it)

  4. In that file comment the code which currently displays the SALE badge, and instead add code for discount.

Basically find this code

{{ ‘products.product.on_sale’ | t }}>

And replace it with this (as shown in picture)

{%- if compare_at_price > price -%}> {% assign discount = compare_at_price | minus: price | times: 100.0 | divided_by: compare_at_price | round %}> > {{ discount }}% OFF> > {% endif %}> > {% comment %}> > {{ ‘products.product.on_sale’ | t }}> > {% endcomment %}

After you do that you will be able to see something like this on your product page

Thanks

Yash Garg

3 Likes