I'm trying to print GranTotal on email when a customer make a new order, right now I have used those variables on System → Transactional Emails:
(a)
{{var Total}}
But doesn't show total
(b)
{{var order.getGrandTotal()}}
But I´m getting a reply with 4 decimals such as: 1900,0000 And we don't use decimals, so that reply confuses my customers.
I will appreciate a full reply of what I could do... Thanks!
You need to modify the template parameters to format to two decimal places.
e.g. Search your codebase for:
$mailer->setTemplateParams(
When you find the transnational email you want to modify (in this case it seems you want to edit new order emails, so likely in this file:
app\code\core\Mage\Sales\Model\Order.php
Copy the file to:
app\code\local\Mage\Sales\Model\Order.php
Then edit the following code:
FROM:
$mailer->setTemplateParams(array(
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml
));
TO:
$mailer->setTemplateParams(array(
'formatted_total' => sprintf('%.2F', $this->getData( 'grand_total' ) ),
'order' => $this,
'billing' => $this->getBillingAddress(),
'payment_html' => $paymentBlockHtml
));
To get the thousands separator use:
'formatted_total' => number_format( $this->getData( 'grand_total' ), 2, '.', ',' ),
Then edit the email template:
app/locale/en_US/template/email/sales/order_new.html
To output the new variable where you want it to appear.
var formatted_total