Php 将回复电子邮件地址更改为特定电子邮件通知
我试图在订单中添加便笺时,将不同的电子邮件回复添加到发送给客户的通知中。 到目前为止,我已经:Php 将回复电子邮件地址更改为特定电子邮件通知,php,wordpress,woocommerce,header,email-notifications,Php,Wordpress,Woocommerce,Header,Email Notifications,我试图在订单中添加便笺时,将不同的电子邮件回复添加到发送给客户的通知中。 到目前为止,我已经: add_filter( 'woocommerce_email_headers', 'add_replyto_emails_header', 10, 4 ); function add_replyto_emails_header( $headers, $email_id) { $replyto_email = 'store_owner@gmail.com'; $email_status
add_filter( 'woocommerce_email_headers', 'add_replyto_emails_header', 10, 4 );
function add_replyto_emails_header( $headers, $email_id) {
$replyto_email = 'store_owner@gmail.com';
$email_status = array( 'wc_email_customer_note', 'customer_note');
if ( in_array( $email_id, $email_status)) {
$headers .= "Reply-To: " . $replyto_email . "\r\n";
}
error_log( print_r( $headers, true ) );
return $headers;
}
电子邮件已发送,但标题未修改。我猜email_status数组中的状态不正确,我找不到此电子邮件的id的任何其他引用。如果您查看,您将看到对于发送给客户的所有通知(也就是“customer_note”电子邮件通知),您会得到:
代码进入活动子主题(或活动主题)的functions.php文件。它应该有效
$header .= 'Reply-to: ' . $this->get_from_name() . ' <' . $this->get_from_address() . ">\r\n";
// Change reply to name
add_filter( 'woocommerce_email_from_name', 'change_reply_to_name', 10, 2 );
function change_reply_to_name( $from_name, $wc_email ){
if( 'customer_note' === $wc_email->id ) {
$from_name = ''; // Empty name
}
return $from_name;
}
// Change reply to adress
add_filter( 'woocommerce_email_from_address', 'change_reply_to_address', 10, 2 );
function change_reply_to_address( $from_email, $wc_email ){
if( 'customer_note' === $wc_email->id ) {
$from_email = 'store_owner@gmail.com';
}
return $from_email;
}