我正试图添加一个过滤器,以仅更改客户的“新订单”和“已发送电子邮件”的回复地址。我尝试使用此解决方案Change "reply to" email address in all Woocommerce emails notifications。它适用于客户,但现在商店所有者的电子邮件没有收到任何新订单的电子邮件。我想商店所有者的电子邮件没有收到新订单的电子邮件,因为它的回复地址相同。有没有办法只更改客户的新订单和已寄出电子邮件的答复?
请帮助!
答案 0 :(得分:1)
如果与收件人相同,这应该防止将回复添加到电子邮件标题:
/**
* Change reply to email address for customer emails.
*
* @param array $header - The email headers.
* @param string $email_id
* @param object $order WC_Order
* @param object $email - The WC_Email class object for this particular email.
* @return array
*/
function change_reply_to_email_address( $header, $email_id, $order, $email ) {
// HERE below set the name and the email address
$reply_to_name = 'Jack Smith';
$reply_to_email = 'jack.smith@doamin.tld';
// Set the reply to email only if it's not one of the recipients.
if( false !== strpos( $reply_to_email, $email->get_recipient() ) ) {
$header = "Content-Type: " . $email->get_content_type() . "\r\n";
$header .= 'Reply-to: ' . $reply_to_name . ' <' . $reply_to_email . ">\r\n";
}
return $header;
}
add_filter( 'woocommerce_email_headers', 'change_reply_to_email_address', 10, 4 );
似乎没有办法检查电子邮件是否为管理员电子邮件,因此,您可以有条件地检查特定的电子邮件ID。