首页 > 解决方案 > 在所有 Woocommerce 电子邮件通知中更改“回复”电子邮件地址

问题描述

在 Woocommerce 中,我想更改应始终用作所有电子邮件通知的回复地址的电子邮件地址。

Woocommerce 怎么可能做到这一点?

标签: phpwordpresswoocommercehook-woocommerceemail-notifications

解决方案


以下将更改所有电子邮件通知中的“回复”电子邮件地址(和名称):

add_filter( 'woocommerce_email_headers', 'change_reply_to_email_address', 10, 3 );
function change_reply_to_email_address( $header, $email_id, $order ) {

    // HERE below set the name and the email address
    $reply_to_name  = 'Jack Smith';
    $reply_to_email = 'jack.smith@doamin.tld';

    // Get the WC_Email instance Object
    $email = new WC_Email($email_id);

    $header  = "Content-Type: " . $email->get_content_type() . "\r\n";
    $header .= 'Reply-to: ' . $reply_to_name . ' <' . $reply_to_email . ">\r\n";

    return $header;
}

此代码位于您的活动子主题(或主题)的 function.php 文件中。经过测试和工作(感谢helgatheviking

相关:Woocommerce 新订单电子邮件通知中的自定义“回复”电子邮件标题


注意(更新):从 WooCommerce 3.7 开始,WC_Email实例对象现在作为第 4 个参数包含在挂钩中。


推荐阅读