Hello Magento Friends,

In today’s tutorial, I will explain How to Add a “Download Invoice” Button in Magento 2 Order Email.

Once the payment is completed successfully, an order confirmation email is sent to the customer’s email. Order confirmation email helps customers get detailed information about their orders. You can allow users to easily download order invoice from the order confirmation email itself in Magento 2.

Let’s look at the steps to add download invoice button in the order email in Magento 2.

Steps to Add Download Invoice Button in Order Email in Magento 2:

Step 1: Firstly, go to the below file path

app\code\Vendor\Extension\view\frontend\layout\sales_email_order_items.xml

Then add the code as follows

Step 2: Next, move to the file path as given below

app\code\Vendor\Extension\view\frontend\templates\email\items.phtml

And embed the below code

Step 3: Now navigate to the following file path

app\code\Vendor\Extension\etc\frontend\routes.xml

Then add the below code snippet

Step 4: Next, you need to go to the below-mentioned file path

app\code\Vendor\Extension\Controller\Invoice\Printinvoice.php

And include the code as given below

Step 5: In this step, move to the following file path

app\code\Vendor\Extension\Model\Order\Pdf\Invoice.php

Then incorporate the following piece of code

Step 6: At last, go to the below file path

app\code\Vendor\Extension\Model\Sales\Order\Pdf\Items\Invoice.php

And insert the below fragment of code

Step 7: Finally, run the below commands

Conclusion:

With the help of the above-given steps, you can easily add download invoice button to order emails and improve the user experience. If you have difficulty in the above steps, let me know through the comment box. Share the article with your friends and stay in touch with us for more solutions.

Happy Coding!

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