格式化当前区域设置和货币的价格

时间:2011-07-18 08:10:06

标签: php magento

我用:

$product->getPrice();

获取无格式价格,我可以用ajax计算“数量X价格”。

我想重新格式化当前区域设置和货币的总计。我怎么能这样做?

7 个答案:

答案 0 :(得分:127)

我认为Google本可以回答您的问题;-)请参阅http://blog.chapagain.com.np/magento-format-price/

你可以用

完成
$formattedPrice = Mage::helper('core')->currency($finalPrice, true, false);

答案 1 :(得分:28)

$formattedPrice = Mage::helper('core')->currency($_finalPrice,true,false);

答案 2 :(得分:16)

用另一种货币格式化价格而不是当前货币:

Mage::app()->getLocale()->currency('EUR')->toCurrency($price);

答案 3 :(得分:11)

通过此代码格式化产品清单中的价格

echo Mage::helper('core')->currency($_product->getPrice());

答案 4 :(得分:3)

试试这个:

<?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>

答案 5 :(得分:3)

未格式化和格式化:

$price = $product->getPrice();
$formatted = Mage::helper('core')->currency($price, true, false);

或使用:

Mage::helper('core')->formatPrice($price, true);

答案 6 :(得分:-3)

这是一个很有魅力的答案。适用于任何选择用于商店的货币。

$formattedPrice = Mage::helper('core')->currency($finalPrice, true, false);
相关问题