How can I display a dynamic saved percentage on my store?

Topic summary

A store owner wants to replace a static 30% discount badge (currently set via “edit default theme content”) with a dynamic percentage that calculates the actual savings based on compare-at price and current price.

Proposed Solution:

  • Edit product-template.liquid in the Sections directory
  • Add Liquid code to calculate the percentage: {% assign savedPercentage = product.compare_at_price minus product.price times 100 divided_by product.compare_at_price %}

Current Status:
The original poster attempted the solution but reports it isn’t working, asking if the code needs to be placed in a specific location. The issue remains unresolved with questions about proper implementation.

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

Good morning, I would like to put on my store the dynamic saved percentage, now as you can see is static and is always 30%(I’ve set it by “edit default theme content”). The store’s url is ferrucciokids.myshopify.com and is pass free.

Many thanks in advance, best regards.

Simone Aresta

  1. In the code editor, navigate to the “Sections” directory and open the product-template.liquid file.
{% assign savedPercentage = product.compare_at_price | minus: product.price | times: 100 | divided_by: product.compare_at_price %}
​

Thank you for your answer. The code should be put in a particular place? Cause it doesnt work