【发布时间】:2011-10-07 11:52:06
【问题描述】:
我用:
$product->getPrice();
要获得我可以用 ajax 计算“数量 X 价格”的未格式化价格。
我想以当前语言环境和货币重新格式化总计。我该怎么做?
【问题讨论】:
我用:
$product->getPrice();
要获得我可以用 ajax 计算“数量 X 价格”的未格式化价格。
我想以当前语言环境和货币重新格式化总计。我该怎么做?
【问题讨论】:
试试这个:
<?php echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol(); ?>
【讨论】:
我认为 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);
【讨论】:
通过此代码在产品列表中格式化价格
echo Mage::helper('core')->currency($_product->getPrice());
【讨论】:
未格式化和格式化:
$price = $product->getPrice();
$formatted = Mage::helper('core')->currency($price, true, false);
或使用:
Mage::helper('core')->formatPrice($price, true);
【讨论】:
用于以不同于当前货币的另一种货币格式化价格:
Mage::app()->getLocale()->currency('EUR')->toCurrency($price);
【讨论】:
这是一个迷人的答案。适用于为商店选择的任何货币。
$formattedPrice = Mage::helper('core')->currency($finalPrice, true, false);
【讨论】: