Skip to content

Instantly share code, notes, and snippets.

@rabu81
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rabu81/9363010 to your computer and use it in GitHub Desktop.
Save rabu81/9363010 to your computer and use it in GitHub Desktop.
How to load the total amount in Magento
<?php
// load the latest order
$order = Mage::getModel('sales/order')->loadByIncrementId(Mage::getSingleton('checkout/session')->getLastRealOrderId());
// get the total amount
$amount = number_format($order->getGrandTotal(),2);
// now you can use the variable $amount in the same page, to print the total amount
// important! please add your own error handling to avoid exceptions or errors displayed on the page
?>
<script type="text/javascript">
var _agTrack = _agTrack || [];
// please make sure you set the correct customer code
_agTrack.push({cid:"XXXXX"})
// in this example USD is used for the currency code
// please set your correct currency code or optionally load it dynamically, if you are handling multiple currencies
_agTrack.push({conv:"USD<?php echo $amount;?>"});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment