How to get order data by order id programmatically in magento 2?

Order Data contains the order information like Total summary, Customer Info, Billing, shipping and payment-related data in Magento 2.

Order Entity generated after the Customer Placed Order successfully from the Storefront or Admin Can Place an order from the Magento Back Panel.

Get Order Data By Order Id to retrieve order information using the OrderRepositoryInterface way.

Always Use the Order Repository to fetch order details instead of Order Factory Pattern.

You can get order data by Order id using below code snippets,

public function __construct(
    \Magento\Sales\Api\OrderRepositoryInterface $orderRepository
    $this->orderRepository = $orderRepository;

  *@param int $id The order ID.
public function getOrderData($id)
   try {
      $order = $this->orderRepository->get($id);
   } catch (NoSuchEntityException $e) {
      throw new \Magento\Framework\Exception\LocalizedException(__('This order no longer exists.'));
   return $order;

Call function in template file by below way,

$orderData = $this->getOrderData($data['order_id']);
foreach($orderData as $order) {
	echo "<pre>";print_r($order->debug());

The result will be given order data of specific order id. You can fetch data as per your requirement from the Order Object.