Percentage pill on products instead of sale pill

Topic summary

A Shopify Dawn theme user wants to display sale percentage badges on products instead of generic “Sale” pills. They found existing solutions but couldn’t get them working.

Solution provided:

  • Modify the theme’s price display code to calculate and show discount percentages
  • Edit the card-product.liquid file in the snippets folder
  • Add Liquid code that calculates percentage: (compare_at_price - price) / compare_at_price × 100
  • Search for “badge” in the code and replace with the percentage calculation snippet

Issues encountered:

  • Initial implementation merged percentage value with the price display
  • Percentage appeared in both the badge pill and alongside the price
  • Line numbers didn’t match between different theme versions

Resolution:

  • Remove the duplicate percentage code from the price section
  • Keep only the badge implementation in card-product.liquid
  • Final result displays accurate discount percentages on product cards

The implementation required multiple code adjustments with screenshots provided for guidance. Issue was successfully resolved.

Summarized with AI on November 10. AI used: claude-sonnet-4-5-20250929.

I am using dawn theme, products carry a pill of sale only i want to add a sale percentage pill on them, i have seen some solutions here but none of them seems to work for my store. Store link https://www.tinytrendz.pk/

Follow My Step

  1. open Your Store
    see Screenshote:->
    https://prnt.sc/D2VewTnAnIxe

  2. Open Edit Code

see Screenshote
https://prnt.sc/PnWJ7B0ODXAf

  1. Search Price

https://prnt.sc/zGCsgnbh2Fyp

  1. This Code change New Code Like This

ScreenShote
https://prnt.sc/DTpB3V52_bhn

{% if product.compare_at_price > product.price and product.available %}
    
      {% if product.compare_at_price_max > product.price -%}
        -
        {{-
          product.compare_at_price_max
          | minus: product.price
          | times: 100.0
          | divided_by: product.compare_at_price_max
          | money_without_currency
          | times: 100
          | remove: '.0'
        -}}
        %
      {%- endif %}
    

  {% else %}
    
      {{ 'products.product.sold_out' | t }}
    
  {% endif %}

After changing the code the percentage value is merged with price and is not showing correct discount value.

Go to snippets > card-product.liquid file, in line 93 and change code:

before

after

Code:

{%- assign percent = card_product.compare_at_price | minus: card_product.price | times: 100 | divided_by: card_product.compare_at_price | round -%}
               {{ percent }}%

Line 93 code does not match

Okay Ctrl + F And Type

badge

See This Code

After Replace

{%- assign percent = card_product.compare_at_price | minus: card_product.price | times: 100 | divided_by: card_product.compare_at_price | round -%}
               {{ percent }}%

Screenshot is not visible

See This screenshote Link :–>>

https://prnt.sc/wXhrpNWLUbYa
change With This Code

{%- assign percent = card_product.compare_at_price | minus: card_product.price | times: 100 | divided_by: card_product.compare_at_price | round -%}
               {{ percent }}%

Pill on the product is showing the accurate value but it is also showing percentage value with price which is not correct, ow can i remove it?

you Remove This Screenshote 36% Value remove Right?

https://prnt.sc/a0b554DjZKjl

Yes

  1. open Your Store
    see Screenshote:->
    https://prnt.sc/D2VewTnAnIxe

  2. Open Edit Code

see Screenshote
https://prnt.sc/PnWJ7B0ODXAf

  1. Search Price

https://prnt.sc/zGCsgnbh2Fyp

  1. This Code change New Code Like This

ScreenShote
https://prnt.sc/DTpB3V52_bhn

remove this code.

{% if product.compare_at_price > product.price and product.available %}
    
      {% if product.compare_at_price_max > product.price -%}
        -
        {{-
          product.compare_at_price_max
          | minus: product.price
          | times: 100.0
          | divided_by: product.compare_at_price_max
          | money_without_currency
          | times: 100
          | remove: '.0'
        -}}
        %
      {%- endif %}
    

  {% else %}
    
      {{ 'products.product.sold_out' | t }}
    
  {% endif %}

Add This Code

{%- if show_badges -%}
    
      {{ 'products.product.on_sale' | t }}
    

    
      {{ 'products.product.sold_out' | t }}
    
  {%- endif -%}

Like This Screenshote==>

https://prnt.sc/otelQHofGxyN

Thanks for the help everything seems to be working fine and accordingly.