我使用:
$product->getPrice();
得到未格式化的价格,我可以用ajax计算"数量X价格"。
我想在当前区域设置和货币中重新格式化总数。我该怎么做呢?
我想Google可以回答你的问题;-)参见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());
未格式化和已格式化:
$price = $product->getPrice();
$formatted = Mage::helper('core')->currency($price, true, false);
或使用:
Mage::helper('core')->formatPrice($price, true);
try this:
<?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>
这是一个迷人的答案。
$formattedPrice = Mage::helper('core')->currency($finalPrice, true, false);