Silahkan Melihat Tutorial di website kami dengan nyaman ENJOY YOUR LIFE ☕

How to display discount percentage for Special Price in Magento


If price. phtml file not in your theme, please copy from here

copy

App/design/frontend/base/default/template/catalog/product/price.phtml

paste
App/design/frontend/default/YOURTEMPLATE/template/catalog/product/price.phtml


first set special price in magento product.

<?php

$_actualPrice = $_store->roundPrice($_store->convertPrice($_product->getPrice()));
$_convertedFinalPrice = $_store->roundPrice($_store->convertPrice($_product->getFinalPrice()));


$_discountPercentage = round((($_actualPrice-$_convertedFinalPrice)/$_actualPrice)*100);

echo $_discountPercentage."%";

?>

this code use for display discount in percentage.

$_actualPrice  it's retailer of product
$_convertedFinalPrice it's special price.

if you want to check that 

<?php
echo "retail price:- ".$_actualPrice."</br>";
echo "special price:- ".$_convertedFinalPrice."</br>";
?> 

if you want round figger value in percentage. then
<?php

echo $_discountPercentage."%";

?>
this value display round price discount 

if you want price in float check below code

<?php

$_discountPercentage = number_format((float)$_discountPercentage, 2, '.', '');

echo $_discountPercentage."%";

?>
it will diplay value decimal two digit.like 20.00%








0 komentar:

Post a Comment

How to display discount percentage for Special Price in Magento