简体   繁体   English

添加供应商自定义字段 email 地址作为 BCC 到 woocommerce email 新订单

[英]Add a Supplier custom field email address as BCC to woocommerce email New Order

I have a holiday letting wordpress site which has the advanced custom field "Supplier Email" in the add listing page.我有一个假期让 wordpress 站点在添加列表页面中有高级自定义字段“供应商电子邮件”。 When a rental is booked the Supplier Email needs to be added to the woocommerce New Order email under BCC, i have tried numerous options but they have not worked, the Supplier Email is in the post meta so it needs to be pulled in to the new order email. When a rental is booked the Supplier Email needs to be added to the woocommerce New Order email under BCC, i have tried numerous options but they have not worked, the Supplier Email is in the post meta so it needs to be pulled in to the new订购 email。 This is the code i have in my functions.php file:这是我的函数中的代码。php 文件:

add_filter( 'woocommerce_email_headers', 'bcc_to_email_headers', 10, 3 );
function bcc_to_email_headers( $headers, $email_id, $order ) {

if ( $email_id === 'new_order' ) {
     $supplier_email = get_field( 'supplier_email_main',$post_id);

    if ( $supplier_email ) {
        $headers .= "CC: Supplier <" . $supplier_email . ">\r\n";
        $headers .= "BCC: New Order <myemail@gmail.com>" . "\r\n";
    }
}
return $headers;
}

The gmail address(this would go to my personal email, have hidden it here for obvious reasons) i added to BCC didnt even get sent. gmail 地址(这将是 go 到我个人的 email,出于明显的原因将其隐藏在这里)我添加到 BCC 甚至没有发送。 Not sure how to proceed with this, any help would be greatly appreciated, please note i am not a wordpress developer.不知道如何继续,任何帮助将不胜感激,请注意我不是 wordpress 开发人员。 Thanks in advance.提前致谢。

try this尝试这个

add_filter( 'woocommerce_email_headers', 'add_bcc_header', 10, 3 );
function add_bcc_header( $headers, $id, $order ) {
    if ( $id == 'new_order' ) {
        $headers .= 'Bcc: gmailaddress@gmail.com' . "\r\n";
    }
    return $headers;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM