How to Display Discount Percentage and Savings on product page DAWN THEME

How to Display Discount Percentage and Savings on product page DAWN THEME

enovation
New Member
7 0 0

How can we display the percentage of the discount and the amount saved in the product page like the image below:

 

save.PNG

Replies 3 (3)

deepaksharma
Shopify Partner
449 63 99

You can Paste below code 

{%- assign savings = product.selected_or_first_available_variant.compare_at_price
      | minus: product.selected_or_first_available_variant.price
      | times: 100.0
      | divided_by: product.selected_or_first_available_variant.compare_at_price
      | round
      | append: '%'
    -%}
    <p>You Save {{ savings }} (${{ product.compare_at_price | minus: product.price | divided_by: 100 }}.00)</p>

If it does not helps contact me: ds2305187@gmail.com

Deepak Sharma || Shopify Developer || Helping eCommerce Stores
- Was my reply helpful? Accept it as solution
- Was your question answered? Mark it as an Accepted Solution.
-CHAT ON WHATSAPP | BUY ME A COFFEE | MAIL ME: ds2305187@gmail.com
enovation
New Member
7 0 0

Hello @deepaksharma , paste the code in which section?

gr_trading
Shopify Partner
1930 145 201

Hi @enovation ,

 

The code exist on two places card-product.liquid and main-product.liquid, however file name depends on theme structure and vary based on theme and its version. 

 

Below is the code for card-product.liquid and DAWN theme.

{%- 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 }}

 

Same code will work for product too. please refer the below video for detail implementation for both pages.

 

Hope this will helps...

For any custom development WhatsApp or connect at Email ID: gr.trading15@gmail.com for quick consultation. | Shopify Free codes
To support Buy Me a Coffee