Skip to content

Instantly share code, notes, and snippets.

@ViniciusAugusto
Created September 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ViniciusAugusto/b8294e56bfcbde8456d3 to your computer and use it in GitHub Desktop.
Save ViniciusAugusto/b8294e56bfcbde8456d3 to your computer and use it in GitHub Desktop.
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
Find:
<?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; ?>%
</span>
</p>
<?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