Hi dear,
i would like to the percentage discounts is shown on the products. So please help me out. thank you
my page : Nineteenninety.ca. i use Shopify platform.
Hi dear,
i would like to the percentage discounts is shown on the products. So please help me out. thank you
my page : Nineteenninety.ca. i use Shopify platform.
Hello, if your looking to display discount in the form of sales badge
Solution 1:
{% if liquidObject.available %} {% if liquidObject.compare_at_price_max > liquidObject.price and settings.sale_badge %}
{{liquidObject.compare_at_price | minus: liquidObject.price | times: 100 | divided_by: liquidObject.compare_at_price }}% off
{% endif %} {% elsif settings.sold_out_badge %}
{{ ‘products.product.sold_out’ | t }}
{% endif %}
reference: https://youtu.be/e02L1tvETwk
Solution 2:
Add this line of code to below variant price
Note: this code is not flexible and if fixed onthe 1st discount shown
Hi @chaungo
Please follow these steps:
badge price__badge-sale
Please add the following code after {{ ‘products.product.on_sale’ | t }}
{{target.compare_at_price | minus: target.price | times: 100 | divided_by: target.compare_at_price }}% off
{{product.compare_at_price | minus: product.price | times: 100 | divided_by: product.compare_at_price }}% off
I hope that it will work for you.
Thank you! That worked for me
Hi @lojasodi
We’re happy to see that our suggestion helped you solve the issue. Can you kindly give us a like and mark it as a solution? This can be a reference for other merchants if they have an issue like you.
Thanks in advance.
Hi BSS! I liked the comment but cannot mark as solution as I am not the question’s owner.
Thank you! Worked perfectly for me!
Hi @chaungo ,
Please refer the below code to implement the same.
{%- 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 }} OFF
To get details like line number and implement the same on product page request you to refer the below video.