How To Replace "Sale" Tag With "Discount Percentage"? (Minion Theme)

Topic summary

A Shopify store owner using the Minion theme is attempting to replace the standard “Sale” tag with a dynamic discount percentage display on product cards.

Initial Problem:

  • User tried implementing code from previous solutions but encountered errors
  • Screenshots show error messages in the theme editor

Troubleshooting Steps:

  • First code snippet provided used product.selected_or_first_available_variant to calculate discount percentage
  • This approach failed, likely due to incorrect object reference in the card-product.liquid file

Updated Solution:

  • Revised code now uses card_product.selected_or_first_available_variant instead
  • The calculation formula: ((compare_at_price - price) / compare_at_price * 100) rounded to 0 decimal places
  • Code must be added to the card-product.liquid file specifically

Current Status:
The discussion remains ongoing with the latest code suggestion awaiting implementation and testing. The key issue appears to be using the correct product object reference for collection page contexts.

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

Hi, I tried to Replace “Sale” Tag With “Discount Percentage”? (Minion Theme), using the code provided in other answers, but it shows error like this.

my website is: https://babycoo.com.au/

Hey @Babycoo ,

Please use below code:

{% assign price = product.selected_or_first_available_variant.price %}
{% assign compare_at_price = product.selected_or_first_available_variant.compare_at_price %}
{% assign discount_percentage = compare_at_price
| minus: price
| times: 100.0
| divided_by: compare_at_price
%}
-{{ discount_percentage | round: 0 }}% off

Thanks,

Ritu

Hi,

It shows this error

Hello @Babycoo ,

Are you adding this into card-product.liquid ?

@Babycoo ,

Try this code:

{% assign price = card_product.selected_or_first_available_variant.price %}
{% assign compare_at_price = card_product.selected_or_first_available_variant.compare_at_price %}
{% assign discount_percentage = compare_at_price
| minus: price
| times: 100.0
| divided_by: compare_at_price
%}
-{{ discount_percentage | round: 0 }}% off