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...
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025