2017-08-30 29 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; 
}