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...
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024