In this blog, We will see how to get order details by using order id in magento 2. Order details contains the order information like Total summary, Customer Information, Billing, shipping and payment-related data in Magento 2.

Using Dependency Injection (DI), You can use inject \Magento\Sales\Api\OrderRepositoryInterface class to get order details using order id.

Below way, you can get order details using order id in Magento 2.

1. Create a OrderDetails.php file in the app/code/Magespark/OrderDetails/Block folder with the following code: 2. Create a template.phtml file in the app/code/Magespark/OrderDetails/view/frontend/templates folder with the following code: $block variable is referencing our block class and we are calling the method getOrderDetails which is returning the string Order Object. Happy integrating! 😊