I want to add a custom parameter in the invoice template and display that template. so please give me any solution on how to do that?


There is an observer for passing custom parameters to invoice template. Try the below one in your custom module.


<event name="email_invoice_set_template_vars_before">
    <observer name="vendor-add-custom-field-data-invoice" instance="Vendor\Module\Model\Observer\Invoice\EmailTemplateVars"/>


namespace Vendor\Module\Model\Observer\Invoice;

class EmailTemplateVars implements \Magento\Framework\Event\ObserverInterface
    protected $helper;

    public function execute(\Magento\Framework\Event\Observer $observer)
       $transport = $observer->getTransport();
       $order = $transport['order'];

       $transport['my_custom_field'] = "test";        
  • Thank You for your response but not working for me.. – Vishal Baraiya Sep 18 at 9:36
  • did you clear cache after creating module and setup upgrade?? – Vishnunath Sep 19 at 12:34
  • thanks, I have run command but not working for me. – Vishal Baraiya Oct 2 at 5:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.