【问题标题】:Followup - Woocommerce different headers for each email types跟进 - Woocommerce 每种电子邮件类型的不同标题
【发布时间】:2018-05-16 21:29:11
【问题描述】:

目标 将某些特定电子邮件的默认 email-header.php 替换为自定义电子邮件标题。我希望指向单独的电子邮件标头模板文件。

我有 WordPress : 4.9.1 Woocommerce:3.2.5

这是一个基于此处提供的解决方案的问题: Woocommerce different headers for each email types

我在这里遵循@helgatheviking 提供的代码解决方案:https://stackoverflow.com/a/27406663/8044005

可能由于 WP 和 WC 的变化,之前提供的解决方案无法正常工作

在我的functions.php中有

    function so_27400044_remove_email_header(){
    remove_action( 'woocommerce_email_header', 'email_header');
}
add_action( 'init', 'so_27400044_remove_email_header' );

我为此管理员新订单电子邮件创建了一个新的头文件,并在我的 admin-new-order.php 中添加了引用

<?php do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<?php wc_get_template( 'emails/admin-new-order-header.php', array( 'email_heading' => $email_heading ) ) ; ?>

当我测试这封电子邮件时,我得到了两个标题!我创建的新标题也存在!

请指导我。

非常感谢!

【问题讨论】:

标签: php wordpress woocommerce header email-notifications


【解决方案1】:

由于目前无法在 WooCommerce 3.2+ 中删除默认电子邮件标题,您应该从这些特定的电子邮件模板中删除以下代码行:

<?php do_action( 'woocommerce_email_header', $email_heading, $email ); ?>

然后只需添加(您的自定义模板):

<?php wc_get_template( 'emails/admin-new-order-header.php', array( 'email_heading' => $email_heading ) ) ; ?>

我暂时没有看到其他方式。

【讨论】:

猜你喜欢
  • 2015-02-08
  • 2017-06-11
  • 2020-09-10
  • 1970-01-01
  • 2017-06-15
  • 2019-04-23
  • 1970-01-01
  • 2018-01-07
  • 2020-06-14
相关资源
最近更新 更多