How to Add Custom Field in Invoice Totals in Magento 2 Invoice Email

How to Add Custom Field in Invoice Totals in Magento 2 Invoice Email

An invoice is an official document that includes a detailed description of a purchase, quantity, price, shipping cost, sales tax, total, etc.

Magento 2 allows configuring invoice emails to send the customers a detailed invoice when they place an order and complete the payments.

Sending an invoice through email helps enhance your store’s brand identity as well as makes the whole transaction legal and reliable. Moreover, it’s an interactive way to boost the user experience and avoid any legal issues in the future.

The default Magento 2 offers multiple options in the invoice email. However, what if you want to add a custom field in the invoice email?

For instance, you’ve added extra charges on the packaging or product personalization. Or even offered a discount based on the store credit value. Now, the total amount is calculated considering these additional charges or discounts.

However, the email invoice does not add custom charges by default.

In such a case, it can create confusion for the customers if the grand total in the invoice email does not match the total amount they paid.

So, in order to display the manually added charges, one has to follow the below method to add custom field in invoice totals in Magento 2 invoice email.

Method to Add Custom Field in Invoice Totals in Magento 2 Invoice Email

  1. Create registration.php file at app\code\Vendor\Module and use the below code.
  2. Create module.xml file at app\code\Vendor\Module\etc

  3. Create sales_order_invoice.xml file at app\code\Vendor\Module\view\frontend\layout

  4. Create Total.php file at app\code\Vendor\Module\Block

The invoice mail will look something like this:

How to Add Custom Field in Invoice Totals in Magento 2 Invoice Email

That’s it.

If you have queries, feel free to ask in the Comments section below.

I would like to solve your problem.

Don’t forget to share this post with Magento Community via social media.

Thank you.

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

5
(based on 18 Reviews)

Kanchi is a Magento Developer at Meetanshi. Apart from that, she is into dancing. In her free time, she likes to make handmade art and craft.

1 comments On How to Add Custom Field in Invoice Totals in Magento 2 Invoice Email

Leave a reply:

Your email address will not be published.