[英]Extending confirmation emails Magento 2
我想在 magento 2 中将条件文本添加到我的确认电子邮件中。如:
{{if order contains item }}
text
{{else order doesnt contain item}}
other text
目前我知道电子邮件显示的项目如下:
{{layout handle="sales_email_order_items" order=$order area="frontend"}}
这个可以配置吗?
谢谢
为此,我使用外部 phtml 模板:
在设计区,创建你要修改的模块,我你的情况,是Magento_Sales
在模板目录中添加 /email/your-template.phtml :
Magento_Sales
/email
the-email-to-modify.html
/templates
/email
your-template.phtml
在 your-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'}}
等等 ^^
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.