I am trying to getting order,customer and item details on order success page.

 $orderid =$block->getOrderId();
 $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
 $order = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($orderid);

echo "<pre/>";

Is anyone have idea how to get using by directly Object Manager?

Please help me.


1 Answer 1


This is the proper way to get order details.

protected $order;

public function __construct(
    \Magento\Framework\App\Helper\Context $context,
    \Magento\Sales\Model\Order $order
    $this->order = $order;

public function getOrderDetails($incrementId)
    $orderDetail = $this->order->loadByIncrementId($incrementId);
    return $orderDetail;

Once you get $orderDetail object properly, then use following code to get Billing, Shipping and Order Item.

<?php $billingAddress = $orderDetail->getBillingAddress()->getData(); ?>
<?php $shippingAddress = $orderDetail->getShippingAddress()->getData(); ?>
<?php $_items = $orderDetail->getAllVisibleItems(); ?>

For Object Manager

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();
$orderData = $objectManager->create('Magento\Sales\Model\Order')->loadByIncrementId($block->getOrderId()); 

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.