格式化当前区域和货币的价格
我用 :
$product->getPrice(); 得到我可以用ajax计算“数量X价格”的无格式价格。
我想重新格式化当前的语言环境和货币。 我怎样才能做到这一点?
我认为谷歌可以回答你的问题;-)请参阅http://blog.chapagain.com.np/magento-format-price/ 。
你可以做到这一点
 $formattedPrice = Mage::helper('core')->currency($finalPrice, true, false); 
 $formattedPrice = Mage::helper('core')->currency($_finalPrice,true,false); 
用另一种货币来格式化价格:
 Mage::app()->getLocale()->currency('EUR')->toCurrency($price); 
通过这个代码在产品列表中格式化价格
 echo Mage::helper('core')->currency($_product->getPrice()); 
尝试这个:
 <?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?> 
未格式化和格式化:
 $price = $product->getPrice(); $formatted = Mage::helper('core')->currency($price, true, false); 
或使用:
 Mage::helper('core')->formatPrice($price, true); 
这是一个迷人的答案。 适用于任何选定的商店货币。
 $formattedPrice = Mage::helper('core')->currency($finalPrice, true, false);