2017-08-30 22 views
0

有一堆example使用这个woocommerce钩子woocommerce_email_recipient_customer_completed_order。所以我将它添加到functions.php中,并将几个示例收件人连接起来作为测试,但只有购买者会收到一封电子邮件。它似乎并没有像这个过滤器被调用,因为如果我打开调试和error_log(...)日志文件中没有任何东西。woocommerce_email_recipient_customer_completed_order没有被调用的钩子

这是不是有工作原因?我试图将优先级提高到99,但这也不起作用。该网站使用所有默认设置,并且不覆盖任何模板。

add_filter('woocommerce_email_recipient_customer_completed_order', 'custom_woocommerce_add_email_recipient', 10, 2); 
function custom_woocommerce_add_email_recipient($recipient, $order) { 
    $recipient = $recipient . ', [email protected], [email protected]'; 
    return $recipient; 
} 
+0

请问,这不是好的行为和公平的方式,所以无论如何我删除我的答案... – LoicTheAztec

回答

0

当我了解Woocommerce它看起来像这个网站只是竟把处理,所以我不得不使用customer_processing_order邮件ID而不是得到这个工作(感谢@LoicTheAztec用于验证customer_completed_order钩作品),而不是使用woocommerce_email_recipient_customer_processing_order挂钩我使用woocommerce_email_headers并检查邮件ID。

add_filter('woocommerce_email_headers', 'woocommerce_email_headers_add_recipient', 10, 3); 
function woocommerce_email_headers_add_recipient($headers, $mail_id, $order) { 
    if($mail_id == 'customer_processing_order') { 
     $member = null; 
     $memberMail = null; 
     foreach($order->get_meta_data() as $item) { 
      if ($item->key === 'member_name') { 
       $member = $item->value; 
       $memberMail = $this->getMemberMail($member); 
       $headers .= "BCC: {$member} <{$member_mail}>\r\n"; 
       break; 
      } 
     } 
    } 
    return $headers; 
}