Question

Comment puis-je faire écho grand total sans le symbole $ attaché à lui?

Am en utilisant le code suivant pour afficher grand total

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

en ce moment, il affiche $50.00, mais je veux seulement obtenir 50.00, comment puis-je faire la même chose?

Je vous remercie à l'avance.

Était-ce utile?

La solution

Essayez ceci:

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

Il vous obtiendrez le grand total dans ce format 50.0000. Si vous ne souhaitez que 2 décimales utilisent ceci:

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

Autres conseils

Vous pouvez utiliser le modèle directory/currency, il a une fonction qui comprendront la localisation standard, mais il peut aussi être personnalisé. Il a les options suivantes:

  1. prix,
  2. Options (dans ce cas NO_SYMBOL),
  3. inclure conteneur,
  4. Les crochets add

Vous pouvez l'utiliser comme suit et il convertira 15000.59863 en 15.000,60 pour un set-up allemand, 15,000.60 pour un set-up anglais et 15000,60 pour un set-up français:

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

S'il vous plaît Essayez ceci en dessous d'un code de ligne Il travaille pour moi.

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

essayez ceci:

$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);
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top