Magento 1.9 Product – Show Product Discount Percent

imagemagento-1.9product

I would like to show discount percentage on image as badge (refer image 2). I followed the instructions from http://www.customy.com/blog/show-product-discount-percent-in-magento/ and managed to show discount percentage on product page (refer image 1).

I tried:

app/design/frontend/yourpackage/yourtheme/template/catalog/product/price.phtml

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

Now I got result as:

1.
enter image description here

Now I need to show discount percentage on product image too like

2.
enter image description here

What should I do to show discount badge on product image?
I'm using magento 1.9.0.1 RWD theme

Best Answer

as i seen in your question image you need this effect on product detail page so have to edit media.phtml

app\design\frontend\YOUR_PACKAGE\YOUR_THEME\default\template\catalog\product\view\media.phtml

And in that you have to do same coding to get this value. you can make wrapper class which is override to product image with some dynamic text over product image like as you want.

you can use css like in this page

http://techdem.centerkey.com/2013/01/ribbon-banner-css-transform-rotate-45.html

hope this will sure help you.

Related Topic