[英]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.