Magento 1.7 – Show Amount Saved as Currency and Percentage per product

  • by

An interesting snippet of code landed on my desk today:

<?php if($_finalPrice < $_price): ?>
 $_savePercent = 100 - round(($_finalPrice / $_price) * 100); 
 $_saveAmount = number_format(($_price - $_finalPrice), 2); 
 <p class="yousave">
 <span class="price-label label">You Save: </span>
 <span class="price">
 <strong class="save-amount">&pound;<?php echo $_saveAmount; ?></strong> (<?php echo $_savePercent; ?>%)
 <?php endif; ?>

Obviously this code works out the product price - special price, works out a percentage then outputs that information wherever prices are output.

The code was discovered in


I wouldn't have every spotted it, if the site owner hadn't requested that the You Save price not be visible in the category list view, a simple if loop covered in my next post!

Leave a Reply

Your email address will not be published.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

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