All things Shopify and commerce
How can we display the percentage of the discount and the amount saved in the product page like the image below:
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
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...
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025