🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Get Order Information By Order Id in Magento 2

By Sanjay JethvaUpdated on May 22, 2025 2 min read

The Magento 2 developers know the crazy client requirements

If you have been there too, you might know what I’m talking about. But for newbies who are yet to face them, this post might be helpful!

It gives you the programmatic solution to get order information by order ID in Magento 2.

You can use this solution in different scenarios like restrict order based on the delivery address, offer a specific discount based on the order amount, offer a free product when a customer buys a particular item, etc.

With the below solution, you can get the order details like order items, order amount, billing and shipping addresses, order payment method, billing details, quantity, and the customer name.

Method to Get Order Information By Order Id in Magento 2:

  $orderId = 123;
  $objectManager = \Magento\Framework\App\ObjectManager::getInstance();
  $order = $objectManager->create('\Magento\Sales\Model\OrderRepository')->get($orderId);

 // Get Order Information

  $order->getEntityId();
  $order->getIncrementId();
  $order->getState();
  $order->getStatus();
  $order->getStoreId();
  $order->getGrandTotal();
  $order->getSubtotal();
  $order->getTotalQtyOrdered();
  $order->getOrderCurrencyCode();

  // get customer details

  $custLastName = $orders->getCustomerLastname();
  $custFirsrName = $orders->getCustomerFirstname();

  // get Billing details  

  $billingaddress = $order->getBillingAddress();
  $billingcity = $billingaddress->getCity();      
  $billingstreet = $billingaddress->getStreet();
  $billingpostcode = $billingaddress->getPostcode();
  $billingtelephone = $billingaddress->getTelephone();
  $billingstate_code = $billingaddress->getRegionCode();

  // get shipping details

  $shippingaddress = $order->getShippingAddress();        
  $shippingcity = $shippingaddress->getCity();
  $shippingstreet = $shippingaddress->getStreet();
  $shippingpostcode = $shippingaddress->getPostcode();      
  $shippingtelephone = $shippingaddress->getTelephone();
  $shippingstate_code = $shippingaddress->getRegionCode();

  $grandTotal = $order->getGrandTotal();
  $subTotal = $order->getSubtotal();

  // fetch specific payment information

  $amount = $order->getPayment()->getAmountPaid();
  $paymentMethod = $order->getPayment()->getMethod();
  $info = $order->getPayment()->getAdditionalInformation('method_title');

  // Get Order Items

  $orderItems = $order->getAllItems();

  foreach ($orderItems as $item) {
    $item->getItemId();
    $item->getOrderId();
    $item->getStoreId();
    $item->getProductId();

    print_r($item->getProductOptions());

    $item->getSku();
    $item->getName();
    $item->getQtyOrdered();
    $item->getPrice();
 }

That’s it.

You may want to bookmark this post for future reference!

I’d be very grateful if you help share this helpful post on social media to fellow developers!

Thanks!

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.