How to display Special Price with discount percentage

Posted by Labels: at

If you would like to show your users the discount percentage, on both your product list and product view, simply use the scripts below.

Display on Product List >>
step by step

1. Open file
app/design/frontend/package_name/theme_name/template/catalog/product/price.phtml

2. Right at the top, add the following code,


//get the actual product price
$_wasPrice =  $_store->roundPrice($_store->convertPrice($_product->getPrice()));

//get the special product price
$_specialPrice  =  $_store->roundPrice($_store->convertPrice($_product->getFinalPrice()));


3. Now calculate percentage of the discount price, basic maths people!


//calculate the percentage
$_discountPercentage =  round( ( ( $_wasPrice - $_specialPrice ) / $_wasPrice ) * 100 ) . '%';



4. You may simply echo your discount percentage variable under the class="special-price" div, do not be confused by seeing too many special-price div classes, to avoid confusion display your discount percentage on all the classes.

Display on Product View >>
step by step

...to be continued

Pretty simple, right lol... I hope this article was helpful to you, please leave your question/s on the comments section below and I will do my best to answer back.



Post a Comment

Back to Top