简体   繁体   English

将bcc添加到woocommerce的新订单表单中

[英]Add bcc to new order form for woocommerce

How can I add BCC or CC to the woo commerce, new order email? 如何将BCC或CC添加到woo commerce,new order email?

I think this is the code that is running the new order emails: http://codepad.org/kPTpSIM0 I cant seem to find what I need on Google. 我认为这是运行新订单电子邮件的代码: http//codepad.org/kPTpSIM0我似乎无法在Google上找到我需要的东西。 Thank you in advance. 先感谢您。

I found this but I do not know where it goes: 我发现了这个,但我不知道它在哪里:

add_filter( 'woocommerce_email_headers', 'add_bcc_all_emails', 10, 2);

function add_bcc_all_emails($headers, $object) {

$headers = array();
$headers[] = 'Bcc: Name <me@email.com>';
$headers[] = 'Content-Type: text/html';

return $headers;
}

Well it looks like you have already read this answer as that is the recommended code, though I believe it will add the BCC on all emails and not just new orders. 好吧,看起来您已经阅读了这个答案,因为这是推荐的代码,但我相信它会在所有电子邮件上添加BCC,而不仅仅是新订单。

Instead I would suggest the following: 相反,我建议如下:

add_filter( 'woocommerce_email_headers', 'add_bcc_all_emails', 10, 3);

function add_bcc_all_emails( $headers, $email_id, $order ) {

    if( 'new_order' == $email_id ){
        $headers .= "Bcc: Name <me@email.com>" . "\r\n";
    }

    return $headers;
}

As for "where the code goes", it should be made into a plugin. 至于“代码去哪里”,它应该被制作成一个插件。 Depending on how easily you would like to be able to disable this code in the future you could write it as a regular plugin (disable from Plugins overview) or as a site-specific snippets plugin (permanent until you delete file via FTP). 根据您希望以后能够轻松禁用此代码的程度,您可以将其编写为常规插件 (从插件概述中禁用)或作为特定站点的代码段插件 (永久直到您通过FTP删除文件)。

Found a templorary fix, It's not a BCC or CC, but It seems I can add more than 1 recipient to the email by comma separating the addresses. 找到了一个临时修复,它不是BCC或CC,但似乎我可以通过逗号分隔地址添加超过1个收件人到电子邮件。

would still like to do BCC or CC as well though, if anyone knows how. 如果有人知道如何,仍然会喜欢BCC或CC。

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

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