If price.
phtml file not in your theme, please copy from here
copyApp/design/
frontend/base/default/template/catalog/product/price
.phtmlpasteApp/design/
frontend/default/YOURTEMPLATE/template/catalog/product/price
.phtmlfirst 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