nileco-logo-small-text5
  • HOME
  • PROJECTS
  • SERVICES
  • ABOUT
    • WHO WE ARE
    • TESTIMONIALS
  • MAGENTO BLOG

How to display a “You Save” amount and percentage to Magento’s Special price

Magento How ToJune 12, 2014CJ

In order to display a “You Save” amount and the percentage off the regular price for “Special Price” products in Magento do the following:

  1. Copy the fileapp/design/frontend/base/default/template/catalog/product/price.phtmland place it at the following locationapp/design/frontend/default/YOUR THEME/template/catalog/product/price.phtml
  2. Then in price.phtml that you just copied, right above:
    <?php endif; /* if ($_finalPrice == $_price): */ ?>
    
    add the following code:
    
    <?php if($_finalPrice < $_price): ?>
     <?php 
     $_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">$<?php echo $_saveAmount; ?></strong> (<?php echo $_savePercent; ?>%)
     </span>
     </p>
     <?php endif; ?>
  3. Next adjust your skin/frontend/default/YOUR THEME/css/styles.css file by adding the following (or create your own):
    .yousave { margin:0; }
    .yousave .price-label { }
    .yousave .price { font-weight:normal; color:#900; font-family:verdana, arial, helvetica, sans-serif;}
Previous post Display products from a category on a Magento CMS page Next post Changing the default Tax Class for Magento Products

3 comments. Leave new

dhaval
May 16, 2015 3:48 am

Great!!!
It saves my lots of time
Thanks

Reply
rtech22
September 26, 2015 2:00 pm

use this code to fetch the default currency symbol if you use you site for different region

currency($_saveAmount); ?> (%)

Reply
Cristian
March 17, 2016 10:26 am

It works perfect! but I would like to know how to change the “comma” by a “point” because in my country we use the Peso.
Eg $ 10.000

–Thx!

Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

© 2016 All rights reserved. nileco