February 27, 2020

cm-mini

Thinking Magento

Showing Percentage Saved On Product Page - Magento

So something that isn't included on the frontend of Magento. You Saved xx%. So, here's a little something you can copy and paste into your view.phtml

<?php
$_finalPrice = $this->helper('tax')->getPrice($_product, $_product->getFinalPrice());
$_regularPrice = $this->helper('tax')->getPrice($_product, $_product->getPrice());
if ($_regularPrice != $_finalPrice):
$getpercentage = number_format($_finalPrice / $_regularPrice * 100, 2);
$finalpercentage = 100 - $getpercentage;

echo '<div class"savingbox">YOU SAVE '.number_format($finalpercentage, 0).'% </div>' ;

endif; ?>