I'm trying to get access to the grand total of the order but for some reason am unable to access this variable.
I have tried multiple solutions by creation modules but nothing seems to be working.
success.phtml
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
// @codingStandardsIgnoreFile
?>
<?php /** @var $block \Magento\Checkout\Block\Onepage\Success */ ?>
<!---- Onefeed Tracking Code ---->
<?php
//-------------------------------------------
// GET MAGENTO 2 ORDER VALUES FOR TRACKING CODE
//-------------------------------------------
$orderId = $block->getOrderId();
echo $block->getOrder();
$total = 2;
?>
<script type="text/javascript">
var of_ssid = '362-1';
var cs = '<?php echo $total; ?>';
var oi = '<?php echo $orderId; ?>';
var it = 1;
var id = '';
var pairs = document.cookie.split("; "),
count = pairs.length, parts;
while (count--) {
parts = pairs[count].split("=");
if (parts[0] === "user" && parts[1] === "usr")
id = parts[2];
}
</script>
<script type="text/javascript" language="javascript" src="https://tracking.onefeed.co.uk/t.js"></script>
<noscript>
<img border="0" src="https://tracking.onefeed.co.uk/ProcessProductCheckout.ashx?of_ssid=362-1&cs=<?php echo $total; ?>&it=1&oi=<?php echo $orderId; ?>" />
</noscript>
<!---- End Onefeed Tracking Code ---->
success.php
<?php
namespace Creation\OrderSuccess\Block;
class Success extends \Magento\Checkout\Block\Onepage\Success {
public function getOrder() {
return $this->_checkoutSession->getLastRealOrder();
}
}
echo $block->getOrder() outputs null, if I echo $block->getGrandTotal() I also get null.
I can't seem to figure out where I'm missing the connection to access this data.