Hello Magento Friends,

In today’s tutorial, we will learn about How to Add Custom Fields in Invoice Totals in Magento 2 Invoice Email Programmatically?

An admin sends an invoice to customers when the order is placed. Invoices can be generated in the form of PDFs or sent to customers via email. Automatize the invoice process of your Magento 2 store by installing Magento 2 Auto Invoice & Shipment.

Admin can configure invoice email in Magento 2. The invoice email contains order totals and other information. If you want to show custom fields in invoice totals, follow the steps below.

Steps to Add Custom Fields in Invoice Totals in Magento 2 Invoice Email Programmatically:

Step 1: In the first step you need to create the sales_order_invoice.xml file at the below file path


Then add the code as follows

Step 2: Now create the CustomFieldinInvoice.php file at the following path


Now add the below code


Hence, this way, you can easily add custom fields in invoice totals in Magento 2 invoice email programmatically. If you have any doubts, let me know through the comment box. Share the article with your friends and stay in touch with us.

Happy Coding!

Click to rate this post!
[Total: 3 Average: 5]