簡體   English   中英

WooCommerce - 將新訂單 email 發送到某些地址

[英]WooCommerce - send new order email to certain addresses

我需要根據訂單中的各種因素將新訂單 email 發送到某些 email 地址 - 我從基本測試開始,並認為以下 function 會發送電子郵件,但不會發送電子郵件)。 我究竟做錯了什么?

(是的,我知道可以通過在設置區域中添加輔助 email 來完成以下示例 - 這只是我計划擴展的測試,一旦我開始工作)

add_filter( 'woocommerce_email_headers', 'additional_cc_email_recipient', 10, 3 );
function additional_cc_email_recipient( $headers, $email_id, $order ) {
    if ( $email_id === 'new_order' ){

        $cc_email = "mytestemail@test.com";

        $headers .= 'Cc: ' . $cc_email . '\r\n';
    }
    return $headers;
}

試試這個方法,它對我有用

function additional_cc_email_recipient( $header, $email_id, $order ) {
    if ( $email_id == 'new_order' ) {
        // Prepare the the data
        $formatted_email = utf8_decode('My test <mytestemail@test.com>');

        // Add Cc to headers
        $header .= 'Cc: '.$formatted_email .'\r\n';
    } else {
        // Prepare the the data
        $formatted_email = utf8_decode('My other test <myothertestemail@test.com>');

        // Add Cc to headers
        $header .= 'Cc: '.$formatted_email .'\r\n';     
    }

    return $header;
}
add_filter( 'woocommerce_email_headers', 'additional_cc_email_recipient', 10, 3 );

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM