#php #email #magento2
#php #Адрес электронной почты #magento2
Вопрос:
Я хотел бы добавить условный текст в мои электронные письма с подтверждением в magento 2. Как в:
{{if order contains item }}
text
{{else order doesnt contain item}}
other text
На данный момент я знаю, что в электронном письме отображаются элементы с этим:
{{layout handle="sales_email_order_items" order=$order area="frontend"}}
Это настраивается?
Спасибо
Ответ №1:
Для этой цели я использую внешний шаблон phtml :
-
в области дизайна создайте модуль, который вы хотите изменить, в вашем случае это Magento_Sales
-
в каталоге шаблонов добавьте /email/your-template.phtml :
Magento_Sales
/email
the-email-to-modify.html
/templates
/email
your-template.phtml
В вашем-template.phtml используйте php как обычно
<?php
//your code, with the test
// to get the variables use:
$myvar=$this->getData('myvar');
...?>
<p>Hello <?php echo $myvar; ?></p>
В шаблоне HTML the-email-to-modify.html , вы можете включить свой шаблон и отправить любые переменные, которые вы хотите, здесь имя клиента :
<h1>The title</h1>
{{block class='Magento\Framework\View\Element\Template'
myvar=$customer.name area='frontend'
template='Magento_Sales::email/your-template.phtml'}}
et voila ^^