1

Im setting up Google trusted stores and I need to call some information which I can do but the format is wrong.

From what I can see there is 2 extra zero's at the and of the numbers which I need to remove.

Required format: "123.45" Your value: "123.4500".

$orderId = $this->getOrderId();
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
$customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
$address = $order->getShippingAddress();

The code I need to modify is:

<span id="gts-o-total"><?php echo $order->getGrandTotal(); ?></span>
<span id="gts-o-discounts">-<?php echo $order->getDiscountAmount(); ?></span>
<span id="gts-o-tax-total"><?php echo $order->getTaxAmount(); ?></span>
<span class="gts-i-price"><?php echo $item->getBasePrice(); ?></span>
1

You can use basic PHP float with 2 decimal places concept.

See at https://stackoverflow.com/questions/12706519/php-float-with-2-decimal-places-00

here you need to change.

$order->getGrandTotal() to number_format((float)$order->getGrandTotal(),2);

$order->getDiscountAmount() to number_format((float)$order->getDiscountAmount(),2);

$order->getTaxAmount() to number_format((float)$order->getTaxAmount(),2);

$item->getBasePrice() to number_format((float)$item->getBasePrice(),2);

10
  • Hey, so i just add this to my current helper list? as that didnt work. Is there something else I need to be doing also? Thanks. – Mike Tim Turner Sep 21 '15 at 9:50
  • answet update,please check.. – Amit Bera Sep 21 '15 at 10:01
  • Still didnt work :( – Mike Tim Turner Sep 21 '15 at 10:08
  • I got: Your value: "<span class="price">£1.00</span>". – Mike Tim Turner Sep 21 '15 at 10:21
  • How would I use stripTags() – Mike Tim Turner Sep 21 '15 at 10:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.