【问题标题】:WooCommerce - send new order email to certain addressesWooCommerce - 向特定地址发送新订单电子邮件
【发布时间】:2020-04-22 15:29:57
【问题描述】:

我需要根据订单中的各种因素将新订单电子邮件发送到某些电子邮件地址 - 我从一个基本测试开始,并认为以下功能可以做到,但没有这样的运气(没有看到 CC:on发送的电子邮件)。我做错了什么?

(是的,我知道可以通过在设置区域中添加辅助电子邮件来完成以下示例 - 这只是我计划扩展的测试,一旦我开始工作)

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;
}

【问题讨论】:

    标签: php wordpress woocommerce hook-woocommerce


    【解决方案1】:

    试试这个方法,对我有用

    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 );
    

    【讨论】:

      猜你喜欢
      • 2017-08-08
      • 2018-10-24
      • 1970-01-01
      • 2023-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-19
      • 2018-08-31
      相关资源
      最近更新 更多