Followup - Woocommerce每种电子邮件类型的不同标题

时间:2017-12-03 06:50:24

标签: php wordpress woocommerce header email-notifications

目标 使用自定义电子邮件标头替换某些特定电子邮件的默认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& S的变化,前面提供的解决方案可能无法正常工作。 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 ) ) ; ?>

当我测试这封电子邮件时,我得到了两个标题!现有以及我创建的新标题!

请指导我。

非常感谢!

1 个答案:

答案 0 :(得分:0)

由于现在无法在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 ) ) ; ?>

目前我还没有看到另一种方式。