首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >扩展确认电子邮件Magento 2

扩展确认电子邮件Magento 2
EN

Stack Overflow用户
提问于 2016-10-04 19:10:57
回答 1查看 512关注 0票数 1

我想在magento 2中的确认电子邮件中添加条件文本。如下所示:

代码语言:javascript
复制
 {{if order contains item }}

 text

 {{else order doesnt contain item}}

 other text

目前,我意识到电子邮件显示的项目如下:

代码语言:javascript
复制
{{layout handle="sales_email_order_items" order=$order area="frontend"}}

这是可配置的吗?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2018-05-08 23:46:55

为此,我使用了一个外部phtml模板:

在设计区域中,创建要修改的模块,在您的情况下,它是Magento_Sales

  • in模板目录/
  • /
  • -template.phtml:

代码语言:javascript
复制
Magento_Sales
    /email
       the-email-to-modify.html
    /templates
        /email
            your-template.phtml

在-template.phtml中,像往常一样使用php

代码语言:javascript
复制
<?php
//your code, with the test
// to get the variables use:
$myvar=$this->getData('myvar');
...?>
<p>Hello <?php echo $myvar; ?></p>

在HTML模板-email-to-modfy.html中,您可以包含模板并发送所需的任何变量,此处为客户名称:

代码语言:javascript
复制
<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 ^^

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39850776

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档