在所有 Woocommerce 电子邮件通知中更改 "reply to" 电子邮件地址

Change "reply to" email address in all Woocommerce emails notifications

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

Woocommerce 如何做到这一点?

以下内容将更改所有电子邮件通知中的 "Reply to" 电子邮件地址(和姓名):

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 3.7 以来,WC_Email 实例对象现在作为第四个参数包含在挂钩中。