I posted this question: How can i get the order total value on success page easily? Magento 2.2 But it never got resolved. Unsure how to rerequest help about it. But I need to get it solved.

I am using magento 2.2.1

The page in question is using:

$block: \Magento\Checkout\Block\Onepage\Success

I am able to get the OrderID but not the grandtotal. I have tried all suggestions I have been able to recreate found on google and on this forum.

I need the grandtotal for creating a postback to the facebook pixel.

I am able to get the orderid using: $lastOrderId = $block->getOrderId();

And I have tried things like:

$lastOrderId = $block->getOrderId();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$order = $objectManager->create('Magento\Sales\Model\Order')->load($lastOrderId);
echo "order id: ". $lastOrderId;
echo $order->getGrandTotal();

Any suggestions? Would very much appreciate some help

2 Answers 2


I had made similar functionality as I need to send the order information to the third party marketing platform from a successful page.

The following script is working for me.

if ($block->getOrderId()):
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$lid = $block->getOrderId();
$order = $objectManager->create('Magento\Sales\Model\Order')->load($lid);
$amount = number_format($order->getGrandTotal(),2);


if you're still facing any issue. let's have skype screen sharing.

You can add me in skype: samumaretiya

Thanks, Sam

  • Sadly it did not work. The amount shows zero. But I added you to skype :) May 1, 2019 at 9:54

A little late, but may help someone else. The above solution doesn't work because loadByIncrementId must be used on this line:

$order = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId ($lid);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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