I wonder if there is a build in magento module which manages emails for non working days. The email sent on non working day will be different than the email sent on working day.
If no module exist, please guide me to the recommended way to do it.
email-templatesmagento2
I wonder if there is a build in magento module which manages emails for non working days. The email sent on non working day will be different than the email sent on working day.
If no module exist, please guide me to the recommended way to do it.
Best Answer
There is no such a thing as you want to and therefore customization is required, however it is quite easy to achieve. I assume that you have basic knowledge on how to create your own standalone module and how to write plugins or override classes. If not then please read resources as the first step:
If you have these basics now, all you have to do is:
There you have a send method but more importantly, there is a protected configureEmailTemplate method [96] which holds configuration logic for the email. all you have to do is add new logic with regards to your data requiremnts and pass your template_id in:
Preferably you will create a new class responsible for resolving template_id with regards to requirements, inject it into a Sender's constructor and delegate revolving template.
To add your own order email template you must create etc/email_templates.xml inside of your module and add new template, eg:
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Email:etc/email_templates.xsd"> <template id="sales_email_order_template" label="New Order" file="order_new.html" type="html" module="Magento_Sales" area="frontend"/> </config>
Element's attributes are obvious and you can always read any file in any module to get more examples.