没有 $ 附上的符号?

我正在使用以下代码显示总数

echo Mage::helper('checkout')->formatPrice(Mage::helper('checkout')->getQuote()->getGrandTotal())

现在正在显示 $50.00 但是我只想得到 50.00, ,我该怎么做?

先感谢您。

有帮助吗?

解决方案

尝试这个:

Mage::helper('checkout')->getQuote()->getGrandTotal()

它将为您提供这种格式的总体总数 50.0000. 。如果只需要2个小数,请使用以下方式:

number_format(Mage::helper('checkout')->getQuote()->getGrandTotal(), 2);

其他提示

您可以使用 directory/currency 模型,它具有一个格式函数,它将包括标准本地化,但也可以自定义。它具有以下选项:

  1. 价格,
  2. 选项(在这种情况下,no_symbol),
  3. 包括容器,
  4. 添加括号

因此,您可以按以下方式使用它,它将转换 15000.59863 进入 15.000,60 对于德国设置, 15,000.60 用于英语设置和 15000,60 用于法国设置:

echo Mage::getModel('directory/currency')->format(
    Mage::helper('checkout')->getQuote()->getGrandTotal(),
    array('display'=>Zend_Currency::NO_SYMBOL),
    false
);

请在下面尝试此行代码,它对我有用。

<?php echo Mage::getModel('directory/currency')->format($_product->getFinalPrice(), array('display'=>Zend_Currency::NO_SYMBOL), false); ?>

尝试这个 :

$grandTotalOfProduct = $order->getData('grand_total');

$currencySymbol = Mage::app()->getLocale()->currency($order-> getOrderCurrencyCode())->getSymbol();

echo  $currencySymbol .number_format(Mage::helper('checkout')->getQuote()->getGrandTotal(), 2);
$grandTotalOfProduct = $order->getData('grand_total');

$currencySymbol = Mage::app()->getLocale()->currency($order-> getOrderCurrencyCode())->getSymbol();

echo  $currencySymbol .number_format(Mage::helper('checkout')->getQuote()->getGrandTotal(), 2);
许可以下: CC-BY-SA归因
scroll top