Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Magento: Show product discount percent
If you wish to show product discount percent next to product price or somewhere on a product page, here’s how you do it.
Open app/design/frontend/yourpackage/yourtheme/template/catalog/product/price.phtml
<?php endif; /* if ($_finalPrice == $_price): */ ?>
Past above it:
<?php // Discount percents output start ?>
<?php if($_finalPrice < $_price): ?>
<?php $_savePercent = 100 - round(($_finalPrice / $_price)*100); ?>
<p class="special-price yousave">
<span class="label"><?php echo $this->__('You Save:') ?></span>
<span class="price">
<?php echo $_savePercent; ?>%
<?php endif; ?>
<?php // Discount percent output end ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment