---
title: "How to Get Invoice Details by Order Id in Magento 2"
url: "https://magecomp.com/blog/get-invoice-details-by-order-id-magento-2/"
date: "2022-12-22T10:00:43+00:00"
modified: "2025-02-14T07:06:11+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 270
reading_time: "2 min read"
summary: "Hello Magento Friends,"
description: "Retrieve invoice information by using the order id in Magento 2. Check out how to accomplish it"
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "Solved: Magento 2 Show Double Thumbnail Image When Select Configurable Products"
    url: "https://magecomp.com/blog/solved-magento-2-show-double-thumbnail-image-when-select-configurable-products/"
  - title: "Magento Performance Optimization: All you need to know (Included How to Improve)"
    url: "https://magecomp.com/blog/magento-performance-optimization-all-you-need-to-know/"
  - title: "How to Get Custom Attribute Value Of Invoice Using Rest API?"
    url: "https://magecomp.com/blog/custom-attribute-value-of-invoice-using-rest-api-in-magento-2/"
---

# How to Get Invoice Details by Order Id in Magento 2

_Published: December 22, 2022_  
_Author: Dhiren Vasoya_  

![How to Get Invoice Details by Order Id in Magento 2](https://magecomp.com/blog/wp-content/uploads/2022/12/How-to-Get-Invoice-Details-by-Order-Id-in-Magento-2-1024x512.webp)

**Hello Magento Friends,**

In this blog, we will learn How to Get Invoice Details by Order Id in Magento 2.
[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2023/10/Magento-2-Speed-Performance-Optimization-Services-CTA-4.webp)](https://magecomp.com/magento-performance-optimization.html)

Invoices are created after the order is placed. It is an important document that states the order agreement between the business and the customer. The invoice includes the order details and order total. Invoices also help owners to receive payments from customers quickly.
In Magento 2, you can automate invoice creation using the [**Auto Invoice and Shipment Extension for Magento 2**](https://magecomp.com/magento-2-auto-invoice-and-shipment.html).
For now, if you want to retrieve invoice information based on order ID, follow the below steps.
## Steps to Get Invoice Details by Order Id in Magento 2:
**Step 1:** We will create a root script for invoice details by order id.
```
<?php
use MagentoFrameworkAppInterface;
try
{
    require_once __DIR__ . '../app/bootstrap.php';
}
catch (Exception $e)
{
    echo 'Autoload error: ' . $e->getMessage();
    exit(1);
}
try
{
	$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
	$objectManager = $bootstrap->getObjectManager();
	$appState = $objectManager->get('MagentoFrameworkAppState');
	$appState->setAreaCode('frontend');

	$orderId = 15; //Enter your Order Id
	$objectManager = MagentoFrameworkAppObjectManager::getInstance();
	$order = $objectManager->create('MagentoSalesModelOrderRepository')->get($orderId);
	$invoiceData = $order->getInvoiceCollection();
	echo "";
	print_r($invoiceData->getdata());
	echo "";
}
catch(Exception $e)
{
	echo "Error : ".$e->getMessage();
}
```

## [![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-4.webp)](https://magecomp.com/services/hyva-theme-development/)

## Conclusion:
This way, you can get invoice details by order id in Magento 2. If you have any doubts, let me know through the comment section. Share the article with other Magento developers and stay in the know so that you do not miss out on our latest blogs and tutorials.
[![Hire Magento Programmer](https://magecomp.com/blog/wp-content/uploads/2025/02/Hire-Magento-Programmer-CTA-4.webp)](https://magecomp.com/services/hire-magento-programmer/)

**Happy Coding!**


---

_View the original post at: [https://magecomp.com/blog/get-invoice-details-by-order-id-magento-2/](https://magecomp.com/blog/get-invoice-details-by-order-id-magento-2/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-11-08 19:59:48 UTC_  
