Get Invoice details by order id programmatically Magento 2.

You can get the invoice data for the specific order by order id in Magento 2.

Using Magento\Sales\Api\InvoiceRepositoryInterface interface, you need to use getList() function to fetch no. of invoice by sales order id.

Using SearchCriteriaBuilder Class, You need to filter by order id and pass search criteria object to getList() method of InvoiceRepositoryInterface.

Using the above way you got the output as invoice records as an array and iterate over a loop to invoice array to fetch no. of different invoice record for an order.

Pass Order id for the function to fetch records of invoice details of an Order.

You got the invoice object for the var_dump in the above output.