Shopify themes, liquid, logos, and UX
Hello
I'm trying to put the percentage on the product card to show sale then percentage off next to it. 'Sale 20% Off'
This is only showing on the product page itself but not on the product card. It only shows the word sale and does not show how much percent is off. Can someone please help me with which code to use for this? This is for Dawn Theme.
Thank you!
Hi @midas8858,
Can you kindly share your store link (with the password, if any) with us? We will check it and suggest you a solution.
If our suggestions are useful, please let us know by giving it a like, marking it as a solution, or donating here ☕.
Product Labels by BSS | B2B Solution & Custom Pricing
Need help from our expert? Kindly share your request with us via community@bsscommerce.com
Hi @midas8858,
Please go to Actions > Edit code > Snippets > price.liquid file, find 'sale_badge_color_scheme' and change code here:
Code:
{%- if use_variant -%}
{%- assign price_save = compare_at_price | minus: price | money -%}
Sale {{ price_save }}% Off
{%- else -%}
{{ 'products.product.on_sale' | t }}
{%- endif -%}
Hope it helps!
Thank you, this only worked when clicking on the product and shows on the product page. I'd like for the amount of % off to show on the product card before going to the product page.
Hi @midas8858,
Please change code:
{%- assign price_save = compare_at_price | minus: price | money -%}
Sale {{ price_save }}% Off
Hope it helps!
@Litos It only worked for the product page. I sent you a direct message to show you which I'm talking about. Kindly check thank you.
Hi @midas8858,
My previous tutorial will help you with this, please change code:
{%- if use_variant -%}
{%- assign price_save = compare_at_price | minus: price | money -%}
Sale {{ price_save }}% Off
{%- else -%}
{{ 'products.product.on_sale' | t }}
{%- endif -%}
=>
{%- assign price_save = compare_at_price | minus: price | money -%}
Sale {{ price_save }}% Off
Hope it helps!
Hi @midas8858 ,
Please use 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 }}
To implement the same on product page please refer the below video.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025