In order to display a “You Save” amount and the percentage off the regular price for “Special Price” products in Magento do the following:
- 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
- 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; ?>
- 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;}
3 comments. Leave new
Great!!!
It saves my lots of time
Thanks
use this code to fetch the default currency symbol if you use you site for different region
currency($_saveAmount); ?> (%)
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!