Magento show product discount in percentage

It is known that for many customers the main factor for making an order is the possibility to have a discount. It is enough to state both a product's retail price and its special price to make a customer happy.

Unfortunately this approach doesn't work well with all customers, as people want to know not only how much they will pay for a certain product but the percentage of the discount they will receive as well. One of the main principles that determines the work of deal sites such as Groupon is to offer various products and services with a discount of 40% and higher. In this case a psychological factor works and it is not important what the initial cost of a product was but the amount of the discount that a customer gains.

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): */ ?>

Add 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 ?>

The result will be:
You can also spice it up with CSS and achieve something like this:
Be sure to hide this discount percent from category products view if you don't need it there.
Enjoy :)


0 comments: