Format of the price
$formattedPrice = Mage::helper('core')->currency($_finalPrice,true,false);
Display products data in cart
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems(); foreach($items as $item) { echo 'ID: '.$item->getProductId().'
'; echo 'Name: '.$item->getName().'
'; echo 'Sku: '.$item->getSku().'
'; echo 'Quantity: '.$item->getQty().'
'; echo 'Price: '.$item->getPrice().'
'; echo "
"; }
Get actual and special price of a product
$_productId = 102; $_product = Mage::getModel('catalog/product')->load($_productId); // without currency sign $_actualPrice = number_format($_product->getPrice(), 2); // with currency sign $_formattedActualPrice = Mage::helper('core')->currency(number_format($_product->getPrice(), 2),true,false); // without currency sign $_specialPrice = $_product->getFinalPrice(); // with currency sign $_formattedSpecialPrice = Mage::helper('core')->currency(number_format($_product->getFinalPrice(), 2),true,false);
Convert price from current currency to base currency and vice-versa
$baseCurrencyCode = Mage::app()->getStore()->getBaseCurrencyCode(); $currentCurrencyCode = Mage::app()->getStore()->getCurrentCurrencyCode(); $price = 150; // convert price from current currency to base currency $priceOne = Mage::helper('directory')->currencyConvert($price, $currentCurrencyCode, $baseCurrencyCode); // convert price from base currency to current currency $priceTwo = Mage::helper('directory')->currencyConvert($price, $baseCurrencyCode, $currentCurrencyCode);
Changing price from any one currency to another
$from = 'USD'; $to = 'NPR'; $price = 10; $newPrice = Mage::helper('directory')->currencyConvert($price, $from, $to);
Round product price
echo Mage::getModel('sales/order')->formatPricePrecision($_product->getFinalPrice(), 3);