WooCommerce:为完成的订单添加第二个电子邮件地址


WooCommerce: Adding a second email address to a completed order

如您所知,WooCommerce没有任何选项可以在邮件设置中为已完成的订单添加第二个电子邮件地址。只有客户才会收到这些邮件我指的不是当每个人都下订单时发送的电子邮件,我指的是当后台管理员完成订单时发送的邮件。

我需要这个的原因:当我们完成订单时,需要通知我们店铺的供应商,以便他们可以发出订购的产品。我找到了一些解决方案,但大多数已经不起作用了,或者当订单发出时,但正如我所说,我需要这个邮件来完成订单。

谢谢!

您可以在functions.php中添加以下内容:

add_filter( 'woocommerce_email_recipient_customer_completed_order', 'your_email_recipient_filter_function', 10, 2);
function your_email_recipient_filter_function($recipient, $object) {
    $recipient = $recipient . ', me@myemail.com';
    return $recipient;
}

唯一的缺点是收件人会看到你的地址&

或者,基于Steve的回答,你可以使用woocommerce_email_headers过滤器。传入的$object允许您仅将此应用于已完成的订单电子邮件:

add_filter( 'woocommerce_email_headers', 'mycustom_headers_filter_function', 10, 2);
function mycustom_headers_filter_function( $headers, $object ) {
    if ($object == 'customer_completed_order') {
        $headers .= 'BCC: My name <my@email.com>' . "'r'n";
    }
    return $headers;
}