1

Im currently inserting google adwords tracking script on my success.phtml and trying to get the total amount from the last order.

Im trying with the following but getting an error:

<?php
    $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
    Mage::getModel('sales/order')->load($orderId);
    $total = (float)number_format($order()->getSubtotal(),2);
?>

This triggers the following error:

Fatal error: Function name must be a string

The line error reference points to: $total = (float)number_format($order()->getSubtotal(),2);

5

Try this one instead.

<?php
    $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
    $order = Mage::getModel('sales/order')->load($orderId);
    $total = (float)number_format($order->getSubtotal(),2);
?>
  • Perfect - works like a charm - thanks for contributing! – user1231561 Apr 21 '15 at 20:04

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.