An interesting snippet of code landed on my desk today:
<?php if($_finalPrice < $_price): ?> <?php <?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; ?>
Obviously this code works out the product price - special price, works out a percentage then outputs that information wherever prices are output.
The code was discovered in
I wouldn't have every spotted it, if the site owner hadn't requested that the You Save price not be visible in the category list view, a simple if loop covered in my next post!