Add event before preparing an email to send out #2983
-
I wish there was an event that would allow me to adjust the contents of an One issue that I'm facing is that our emails don't just go to the order's customer or to our company's email address. Sometimes we need to send a third type of email to a set of users in a Commerce's Up to this point, (and to my knowledge) my code has no way to listen for an event and stop the email from getting prepared, if such an issue occurs. The next event I can respond to is I just wish my module had the option to affect the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @modelesque Thank you for your message. There are a couple of things that you can do here to get things working for you. Firstly, in terms of the sending to the recipients, if you are using Twig to render the output instead of having it fallback to When it comes to adding extra variables, the body of the email is rendered like a standard template so you are able to access template-related events. You could use the "before render template" event to add anything extra you need. There are certainly improvements that we can look into, to make things easier in the future. We will add the process to the list of things to review for future updates. Thanks! |
Beta Was this translation helpful? Give feedback.
Hi @modelesque
Thank you for your message.
There are a couple of things that you can do here to get things working for you.
Firstly, in terms of the sending to the recipients, if you are using Twig to render the output instead of having it fallback to
''
you could set it to something like[email protected]
. You could then be checking for this value in the "before send email" event to prevent sending.When it comes to adding extra variables, the body of the email is rendered like a standard template so you are able to access template-related events. You could use the "before render template" event to add anything extra you need.
There are certainly improvements that we can look into, t…