Shopify: Showing Percentage Discount for "On Special" products

Shopify: How To Show Percentage Discount Saved

Ever wanted to show a neat little You saved 25% on your store, without doing it manually?

In this quick tutorial, we’ll show you how to add a percentage discount to your store – and let Shopify’s Liquid code do all the work.

Quick note: The code in this post won’t work with Themes that use JavaScript to load the prices. That’s a bit more in-depth than what’s described here (this includes our Bilingual Theme, which doesn’t work with this code snippet). We’ll try to update this post at some point to be compatible with it. With other themes, though, it should work. Just a heads up. Thanks!

When Would We Want This?

Most Shopify Themes come with built-in “Sale” banners that allow you to showcase when a product is on special or discounted.  To add to this, you might want to say:

was $20.00 $15.00 – You save 25%

Step 1: Find Your Product Template

In your Shopify Admin, go to Themes > Template Editor > product.liquid.  This is probably where your prices are stored.  Do a search for “price”.  Somewhere in the template, you should see a piece of code:

{{ product. price }}

This is where your theme shows the price of the product: in our example above, $15.00.

Step 2: Insert This Code

Boring note first: Make a backup!

Next, insert the following piece of code wherever you want it to appear.  For example, if you want to show the % discount next to the price, place the code next to {{ product. price }}.

This code calculates and displays the percentage off, rounded to the nearest whole number.
E.g. – You save 25%

{% if product.compare_at_price_max > product.price %}You save {{ 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 %}

What The H*ll Does That Code Do, Exactly?

The code above says:

  • If the product is on special right now ( {% if product.compare_at_price_max > product.price %} )
  • Show the text “You save”, and then
  • A long-winded piece of math, finding the discount ($5) as a percentage of the original price ($20), neatly formatted into a percentage without any decimal points.

Variations

If you want to say something other than “You save”, just change that text in the code snippet.  For example, if you want “Discount: 25%”, just change “you save” to say “Discount:” in the code above.

shopify-show-percentage-discount-300x175

***

Thank you for checking out our Shopify Insider Blog @ Blackbelt Commerce. Please make sure to check out our portfolio. We also have some top blog recommendations for you to check out; More Shopify Design Strategies, 4 Ways to show social proofsShopify incoming sales,   and Social Media.  Keep a lookout for new blog posts.

Do you have any questions? Leave them in the comments below and we will get back to you as soon as possible. Kizunaquant 評判

42 responses to “Shopify: How To Show Percentage Discount Saved

  1. Hi great tutorial!

    Question: any chance this can be applied to a specific collection instead of a store wide discount?

    Best,
    Liz

    1. Hey Liz,
      Glad you liked it! Hmm… that could be done. Could you point me to a link of a collection you’d like to use? If you can clarify a bit further, I’ll do my best to find a way to do it.

      Should be do-able. You could have an if statement in the code, to say:

      if the collection’s title is “collection-title-here”, then show the discount. i.e., in liquid:

      {% if collection.handle == ‘collection-title-here’ %}
      [CODE FOR SHOWING THE DISCOUNT GOES HERE %}
      {% endif %}

      Hope that helps!
      Tristan.

  2. Hi guys,

    I am having a hard time trying to locate the {{ product.price }}. Is there a different term that might have been used?
    I am trying to basically do what this article is talking about.
    If you could help that would be great.

    The Template I am using is Megatronic.

    Regards,
    Ali

    1. Hi Ali,
      I’m not so familiar with the Megatronic theme… but I’d suggest to try looking under “Snippets” if you don’t see it in product.liquid. There many be something like ‘product-form.liquid’ or similar. Try looking in all the “Snippet” files and doing a ctrl+f for “product.price’. Hope that helps!

  3. Hey guys,

    I added this to my product.liquid file and for my products, the selector was {{ product.price | money }}.

    I added the snip of code your provided and it said the following error on the front end:

    “You save Liquid error: wrong argument type nil (expected Regexp)%”

    Thoughts? My theme might use JS, not positive on that. -ZL

    1. Hi Zach,
      Can you point us to your website and let us know which theme you’re doing? I’ll take a look. If your theme uses JS, that’ll be why it’s not working. Cheers! Tristan.

      1. Ever figure out why JS isn’t allowing to render the Liquid correctly? I’m getting the expected Regexp error as well, on the Megatronic theme.

        1. Hey Josh! It’s not so much that JS won’t render the liquid correctly – it’s just that with themes that use JS, the code needed for that is in a different place. In other words – different themes, different code snippets to switch the pricing – that’s why we can’t really give general guidance here in this article. I’m not so sure about megatronic as I’ve not used that theme much – my apologies!

          If you see a file called “Apps.js” or similar, that could be a good place to start. The other option would be to contact Shopify (since they support that theme) and see if they can point you. Best of luck!

  4. Hi I am having somewhat of the same problem with my site.. I have looked for the {{product.price}} in product.liquid form but all I can see is this

    {{ product.price_min | money }}{% if product.price_min < product.compare_at_price_min %} {{ product.compare_at_price_min | money }}{% endif %}

    Would I enter the code just after this??? Also I am looking to enter a store wide discount… How would I do this please???

    1. Hi Callum,
      Hard to say without seeing your site. What’s your URL and your theme? Yes, try entering it after that, refresh, and see what happens. You can always remove it if it doesn’t work.

      For site-wide discounts, I’d recommend the App “Product Discounts” by Bold Apps: https://apps.shopify.com/product-discount

      1. Hi Tristan, my website is ** Could you have a look please I have entered it after the, end%} and nothing has happened…

          1. Hi Callum,
            I had a look at your site. It is indeed using JavaScript to update prices based on the variant, which is why this solution isn’t working (it’s more complex, and very dependant on the theme).

            What this means is: If I go to your product page and select a different frame size, the price updates. That’s how we know it uses JavaScript.

            This would have to be done custom. It could be done in about 2 hours of development ($120/hr). Feel free to let me know if you’d like to go ahead and we could get it set up for you next week. Other question welcome. Cheers – Tristan.

  5. G’day Tristan,

    Hoping for your help and to get this feature on my site.

    I can find similar to “{{ product.price }}” but not exact.

    Any help on the matter would be greatly appreciated.

    1. Hi Jonathan,

      Could you tell me what you found? I can’t see it without looking inside your theme, and it seems to be custom (I took a quick look). If it looks like product.price or similar, that’s probably the one to try. You can make a backup and test it out.

  6. Thanks for the quick reply Tristan.

    here is what I’ve got. The closest i can get has a ‘%’ next to product.price…..

    {% if product.available %}

    {% else %}

    {% endif %}

    {% if product.compare_at_price > product.price %}

    {{ product.compare_at_price_max | money }}
    {{ product.price | money }} INC GST.

    {% else %}
    {{ product.price | money }} INC GST.
    {% endif %}

  7. ok Tristan i think im getting somewhere.

    This is what shows on the website:

    ‘You save Liquid error: wrong argument type nil (expected Regexp)%’

    1. Hi Jonathan,
      Glad you’re making progress. I can’t really go much deeper than that here on this post. If your Theme uses JavaScript, it might be more complicated than in this post (as I mentioned at the top of the post). If you have a web developer, you could get them involved; otherwise, we could help you set it up in about 2 hours (as a mini-project). Feel free to contact us via our “Contact” page if you’d like to. Alternatively you could play around with it a little and perhaps it’ll come good.. hard to tell without seeing inside your theme. Good luck!

  8. Apply the instruction as provided on the retina theme; it showed the offer price vs original price (strike-off); but it does not show the % discount and the text “You Saved”

    Please advise.

    1. Hi Dennis,

      I took a look. You’d need to contact the developers of that theme at outofthesandbox.com, they should be able to help. Cheers! Tristan.

  9. Hello Tristan,

    This works properly with the product.price tag, but what about products with multiple variants? I tried changing all applicable uses of ‘product’ to ‘variant’ but this just displays everything as 0% off. Is there a way to make this work for products with more than one variant?

    Thanks,
    Samantha

    1. Hi Samantha — thanks for reading. Yes, in short, there is a way, but almost every theme is different. You’d probably need to edit the SelectCallback function, which can be quite tricky if you’re involving variants. We’d probably need our Technical Lead to help with this. Which theme are you using?

      1. I actually figured it out. All instances of “product” need to be changed to “variant” as I expected; however, the use of “_max” needs to be dropped entirely for the code to work for variants.

    1. Hi there, try adding:

      | remove: ‘0’

      Guideline: https://docs.shopify.com/themes/liquid-documentation/filters/string-filters#remove

      Hope that helps!

  10. hi! thanks for your kind help, it’s working perfectly but I’m having another kind of problem. When I reload the website, i can see the price, and the x% that’s working perfect, BUT it only appears for 1 second, then this % disappears.
    In this fraction of time, I can see that the % is working ok, but it only lasts for 1 second. Do you know what kind of problem I’m having?
    Thanks again,
    Sebastian

    1. Hi there — try making it “display: block !important;” in the CSS, that may help. Otherwise it might be being hidden by some JavaScript in your theme, best to check with a developer on that 🙂

  11. Nice post Tristan! I used to recommend Shopify store owners to name their discount with the pourcentage off (e.g. 25-off) but it’s kinda bad and easy to cheat 🙂

    You should have a look at my new app called Automatic Discount, it’s complementary to this post: https://apps.shopify.com/automatic-discount-rules

      1. It worked for me but it is showing discount percentage before price, how can i place it after discounted price?

        Thank you

  12. Hello,
    I cannot seem to find product.price anywhere ! I have the Canopy theme installed.
    I found {{ product. price | money }} in product.liquid, but whne i add the code, nothing seems to work.

    please help!

  13. Hi Tristan. I followed your directions and I was able to show the exact phrase only after clicking the product but the percent discount does not automatically shows on my store’s front page. Any help?

    1. Hi There Jether. I will send your message to our support team, and they will help you figure this out. I am happy that you are following our directions.
      Thank you. Cesar Beltran.

  14. Hi Tristan. I followed your directions and I was able to show the exact phrase only after clicking the product but the percent discount does not automatically shows on my store’s front page. Any help?

  15. Your method of explaining the whole thing in this article is in fact good, all be capable of without difficulty
    be aware of it, Thanks a lot.

  16. Thanks for a marvelous posting! I actually enjoyed reading it, you happen to be a great author.
    I will ensure that I bookmark your blog and will often come back down the road.
    I want to encourage you to definitely continue your great job, have a nice morning!

Add Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

;

Comments 42

  1. Hi great tutorial!

    Question: any chance this can be applied to a specific collection instead of a store wide discount?

    Best,
    Liz

    1. Hey Liz,
      Glad you liked it! Hmm… that could be done. Could you point me to a link of a collection you’d like to use? If you can clarify a bit further, I’ll do my best to find a way to do it.

      Should be do-able. You could have an if statement in the code, to say:

      if the collection’s title is “collection-title-here”, then show the discount. i.e., in liquid:

      {% if collection.handle == ‘collection-title-here’ %}
      [CODE FOR SHOWING THE DISCOUNT GOES HERE %}
      {% endif %}

      Hope that helps!
      Tristan.

  2. Hi guys,

    I am having a hard time trying to locate the {{ product.price }}. Is there a different term that might have been used?
    I am trying to basically do what this article is talking about.
    If you could help that would be great.

    The Template I am using is Megatronic.

    Regards,
    Ali

    1. Hi Ali,
      I’m not so familiar with the Megatronic theme… but I’d suggest to try looking under “Snippets” if you don’t see it in product.liquid. There many be something like ‘product-form.liquid’ or similar. Try looking in all the “Snippet” files and doing a ctrl+f for “product.price’. Hope that helps!

  3. Hey guys,

    I added this to my product.liquid file and for my products, the selector was {{ product.price | money }}.

    I added the snip of code your provided and it said the following error on the front end:

    “You save Liquid error: wrong argument type nil (expected Regexp)%”

    Thoughts? My theme might use JS, not positive on that. -ZL

    1. Hi Zach,
      Can you point us to your website and let us know which theme you’re doing? I’ll take a look. If your theme uses JS, that’ll be why it’s not working. Cheers! Tristan.

      1. Ever figure out why JS isn’t allowing to render the Liquid correctly? I’m getting the expected Regexp error as well, on the Megatronic theme.

        1. Hey Josh! It’s not so much that JS won’t render the liquid correctly – it’s just that with themes that use JS, the code needed for that is in a different place. In other words – different themes, different code snippets to switch the pricing – that’s why we can’t really give general guidance here in this article. I’m not so sure about megatronic as I’ve not used that theme much – my apologies!

          If you see a file called “Apps.js” or similar, that could be a good place to start. The other option would be to contact Shopify (since they support that theme) and see if they can point you. Best of luck!

  4. Hi I am having somewhat of the same problem with my site.. I have looked for the {{product.price}} in product.liquid form but all I can see is this

    {{ product.price_min | money }}{% if product.price_min < product.compare_at_price_min %} {{ product.compare_at_price_min | money }}{% endif %}

    Would I enter the code just after this??? Also I am looking to enter a store wide discount… How would I do this please???

    1. Hi Callum,
      Hard to say without seeing your site. What’s your URL and your theme? Yes, try entering it after that, refresh, and see what happens. You can always remove it if it doesn’t work.

      For site-wide discounts, I’d recommend the App “Product Discounts” by Bold Apps: https://apps.shopify.com/product-discount

      1. Hi Tristan, my website is ** Could you have a look please I have entered it after the, end%} and nothing has happened…

          1. Hi Callum,
            I had a look at your site. It is indeed using JavaScript to update prices based on the variant, which is why this solution isn’t working (it’s more complex, and very dependant on the theme).

            What this means is: If I go to your product page and select a different frame size, the price updates. That’s how we know it uses JavaScript.

            This would have to be done custom. It could be done in about 2 hours of development ($120/hr). Feel free to let me know if you’d like to go ahead and we could get it set up for you next week. Other question welcome. Cheers – Tristan.

  5. G’day Tristan,

    Hoping for your help and to get this feature on my site.

    I can find similar to “{{ product.price }}” but not exact.

    Any help on the matter would be greatly appreciated.

    1. Hi Jonathan,

      Could you tell me what you found? I can’t see it without looking inside your theme, and it seems to be custom (I took a quick look). If it looks like product.price or similar, that’s probably the one to try. You can make a backup and test it out.

  6. Thanks for the quick reply Tristan.

    here is what I’ve got. The closest i can get has a ‘%’ next to product.price…..

    {% if product.available %}

    {% else %}

    {% endif %}

    {% if product.compare_at_price > product.price %}

    {{ product.compare_at_price_max | money }}
    {{ product.price | money }} INC GST.

    {% else %}
    {{ product.price | money }} INC GST.
    {% endif %}

  7. ok Tristan i think im getting somewhere.

    This is what shows on the website:

    ‘You save Liquid error: wrong argument type nil (expected Regexp)%’

    1. Hi Jonathan,
      Glad you’re making progress. I can’t really go much deeper than that here on this post. If your Theme uses JavaScript, it might be more complicated than in this post (as I mentioned at the top of the post). If you have a web developer, you could get them involved; otherwise, we could help you set it up in about 2 hours (as a mini-project). Feel free to contact us via our “Contact” page if you’d like to. Alternatively you could play around with it a little and perhaps it’ll come good.. hard to tell without seeing inside your theme. Good luck!

  8. Apply the instruction as provided on the retina theme; it showed the offer price vs original price (strike-off); but it does not show the % discount and the text “You Saved”

    Please advise.

    1. Hi Dennis,

      I took a look. You’d need to contact the developers of that theme at outofthesandbox.com, they should be able to help. Cheers! Tristan.

  9. Hello Tristan,

    This works properly with the product.price tag, but what about products with multiple variants? I tried changing all applicable uses of ‘product’ to ‘variant’ but this just displays everything as 0% off. Is there a way to make this work for products with more than one variant?

    Thanks,
    Samantha

    1. Hi Samantha — thanks for reading. Yes, in short, there is a way, but almost every theme is different. You’d probably need to edit the SelectCallback function, which can be quite tricky if you’re involving variants. We’d probably need our Technical Lead to help with this. Which theme are you using?

      1. I actually figured it out. All instances of “product” need to be changed to “variant” as I expected; however, the use of “_max” needs to be dropped entirely for the code to work for variants.

    1. Hi there, try adding:

      | remove: ‘0’

      Guideline: https://docs.shopify.com/themes/liquid-documentation/filters/string-filters#remove

      Hope that helps!

  10. hi! thanks for your kind help, it’s working perfectly but I’m having another kind of problem. When I reload the website, i can see the price, and the x% that’s working perfect, BUT it only appears for 1 second, then this % disappears.
    In this fraction of time, I can see that the % is working ok, but it only lasts for 1 second. Do you know what kind of problem I’m having?
    Thanks again,
    Sebastian

    1. Hi there — try making it “display: block !important;” in the CSS, that may help. Otherwise it might be being hidden by some JavaScript in your theme, best to check with a developer on that 🙂

  11. Nice post Tristan! I used to recommend Shopify store owners to name their discount with the pourcentage off (e.g. 25-off) but it’s kinda bad and easy to cheat 🙂

    You should have a look at my new app called Automatic Discount, it’s complementary to this post: https://apps.shopify.com/automatic-discount-rules

      1. It worked for me but it is showing discount percentage before price, how can i place it after discounted price?

        Thank you

  12. Hello,
    I cannot seem to find product.price anywhere ! I have the Canopy theme installed.
    I found {{ product. price | money }} in product.liquid, but whne i add the code, nothing seems to work.

    please help!

  13. Hi Tristan. I followed your directions and I was able to show the exact phrase only after clicking the product but the percent discount does not automatically shows on my store’s front page. Any help?

    1. Hi There Jether. I will send your message to our support team, and they will help you figure this out. I am happy that you are following our directions.
      Thank you. Cesar Beltran.

  14. Hi Tristan. I followed your directions and I was able to show the exact phrase only after clicking the product but the percent discount does not automatically shows on my store’s front page. Any help?

  15. Your method of explaining the whole thing in this article is in fact good, all be capable of without difficulty
    be aware of it, Thanks a lot.

  16. Thanks for a marvelous posting! I actually enjoyed reading it, you happen to be a great author.
    I will ensure that I bookmark your blog and will often come back down the road.
    I want to encourage you to definitely continue your great job, have a nice morning!

Add Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Book a Free Strategy Call
Book Your Free Strategy Call
614%avg. organic traffic increase
1,000+Shopify merchants served
5.0 / 5Shopify partner rating
Official Partner: Shopify

Trusted by 1,000+ Shopify Merchants

★★★★★
5.0 / 5.0

Rated by 1,000+ Shopify Merchants

Official Partner

Shopify Plus SEO Expert Agency

614%+

Avg. Organic Traffic Increase

Elite Brands

LA Lakers, Judith Leiber & More

Certified Shopify Plus SEO Expert & Premier Shopify SEO Agency — Serving Stores Since 2015
Verified Client Results

Real Shopify Stores. Real Results.

These aren’t projections — these are verified revenue and traffic results achieved for real Shopify merchants.

ECOMMERCE SEO STRATEGY
Erica Wilson
Shopify 2.0 + AI SEO
+614%Organic Traffic
Organic Traffic
3K → 27.7K
Revenue
$19K → $153K
Timeframe
3 months
LOCAL SEO + SHOPIFY
Biltmore Avenue Family Dentistry
Local Business + Shopify Store
+340%Revenue Growth
Page 1 Rankings
2 → 15+ keywords
Organic Revenue
3x in 6 months
Timeframe
6 months

What Our Clients Say

★★★★★

“I’ve been working with Cesar for several years. Blackbelt has been instrumental in growing our online business through their program that actually works.”

JG
Jeremy Granger
Biltmore Avenue Family Dentistry
★★★★★

“Blackbelt Commerce is a great team to work with. They are extremely knowledgeable in terms of site design, functionality, and SEO.”

JM
Jana Matheson
Judith Leiber NY
★★★★★

“Starting this project I had a vision and Blackbelt Commerce delivered beyond what I expected. I highly recommend them for any ecommerce SEO strategy.”

FH
Falon Henley
Ultimate Weapons
$3M+
Top Client Revenue
614%
Max Traffic Growth
7.5x
Revenue Multiplier
5★
Client Reviews

Ready to start? Call us directly:

+1 (516) 704-9890

Or book a free strategy call online

Frequently Asked Questions

Get answers to the most common questions about our AI SEO services.

What is AI SEO and how is it different from traditional SEO?

AI SEO optimizes your Shopify store to be discovered and recommended by AI platforms like ChatGPT, Google AI Overviews, Perplexity, and Claude — not just traditional search engines. While traditional SEO focuses on keyword rankings and backlinks, AI SEO focuses on structured data, semantic authority, entity optimization, and content that AI systems can parse and cite directly.

How do AI search engines find and recommend Shopify stores?

AI search engines crawl your site’s structured data (Product schema, FAQ schema, reviews), analyze your content’s topical authority, evaluate your brand’s entity presence across the web, and assess technical signals like page speed and mobile experience.

Will AI SEO replace traditional SEO for my Shopify store?

No — AI SEO complements traditional SEO. You still need strong Google rankings, but AI search is growing rapidly. Our approach ensures your store is optimized for both: traditional search engines for direct traffic, and AI platforms for recommendation-based discovery.

How long does it take to see results from AI SEO?

Most clients see measurable improvements within 60-90 days. AI search platforms update their indexes frequently, so optimizations like structured data, entity markup, and content restructuring can show impact relatively quickly compared to traditional SEO.

What Shopify stores benefit most from AI SEO?

Any Shopify store selling products that people research before buying benefits from AI SEO. This includes health and wellness, fashion, electronics, home goods, specialty foods, and B2B products. If customers ask questions before purchasing, AI SEO helps your store appear in those answers.

Do you optimize for ChatGPT, Google AI Overviews, and Perplexity?

Yes. Our AI SEO program covers all major AI search platforms including ChatGPT, Google AI Overviews (SGE), Perplexity, Claude, and Bing Copilot. Each platform has different ranking signals, and our framework addresses all of them.

What is included in your AI SEO audit?

Our AI SEO audit analyzes your current AI search visibility, structured data implementation, content semantic structure, entity presence across the web, technical SEO health, and competitor AI visibility. You receive a detailed report with prioritized recommendations.

How much does AI SEO cost?

AI SEO programs start at $2,500/month for ongoing optimization or $5,000-$15,000 for one-time optimization projects. The investment depends on your store’s size, current SEO foundation, and growth goals. Contact us for a custom quote.

Can you show examples of AI SEO results?

Yes. Our clients have seen 614% organic traffic increases, 340% revenue growth, and consistent appearances in AI-generated product recommendations. We share detailed case studies during our strategy calls.

Do I need traditional SEO before starting AI SEO?

Not necessarily. While a solid traditional SEO foundation helps, we can implement AI SEO alongside traditional optimizations. Many of the technical improvements — structured data, site architecture, content optimization — benefit both traditional and AI search simultaneously.

Ready to Grow Your AI Search Visibility?

Book a free 30-minute strategy call. We’ll analyze your store’s AI search presence and outline a custom growth plan.

GET YOUR FREE AI SEO AUDIT

Or call us directly: +1 (516) 704-9890