【问题标题】:How can I send on-hold WooCommerce email notification to admin as well as customer如何向管理员和客户发送暂停的 WooCommerce 电子邮件通知
【发布时间】:2021-11-05 22:04:33
【问题描述】:

默认情况下,WooCommerce 仅向客户发送暂停订单通知(不知道为什么,因为让商店经理知道订单何时暂停非常重要......)

根据我在这里和 Google 上发现的研究线程,我尝试在我的子主题的 functions.php 中实现以下 sn-ps:Send on-hold order status email notification to admin

add_filter( 'woocommerce_email_headers', 'custom_admin_email_notification', 10, 3);
function custom_admin_email_notification( $headers, $email_id, $order ) {

    if( 'customer_on-hold_order' == $email_id ){
        // Set HERE the Admin email
        $headers .= 'Bcc: My name <my@email.com>\r\n';
    }
    return $headers;
}

我还尝试了来自同一线程的以下 sn-p:

// Send on-hold order status email notification to admin
add_filter( 'woocommerce_email_headers', 'custom_admin_email_notification', 10, 3);
function custom_admin_email_notification( $headers, $email_id, $order ) {

    if( strpos($email_id,'hold') > 0 ){
        $headers .= 'Bcc: Admin User <admin@example.com>'. "\r\n";
    }
    return $headers;
}

当订单从待付款更改为暂停时,这些似乎都不起作用。是的,我已将 sn-ps 中的电子邮件更改为我的管理员电子邮件。我正在寻找一种解决方案,当这种情况自动发生(从待付款到暂停)或在编辑订单时手动发生时,管理员将在客户暂停电子邮件中被密件抄送。

【问题讨论】:

    标签: php wordpress woocommerce email-notifications


    【解决方案1】:
    • 添加 utf8_decode 可能会有所帮助
    • customer_on-hold_order 替换为customer_on_hold_order
    • 使用 Wordpress 5.8.1 和 WooCommerce 5.6.0 测试

    所以你得到:

    function filter_woocommerce_email_headers( $header, $email_id, $order ) {
        // Compare
        if ( $email_id == 'customer_on_hold_order' ) {      
            // Prepare the the data
            $formatted_email = utf8_decode( 'My test <my_test@email.com>' );
    
            // Add Bcc to headers
            $header .= 'Bcc: ' . $formatted_email . '\r\n';
        }
    
        return $header;
    }
    add_filter( 'woocommerce_email_headers', 'filter_woocommerce_email_headers', 10, 3 );
    

    【讨论】:

    • 谢谢!这种方法非常适合我。
    猜你喜欢
    • 2017-06-14
    • 1970-01-01
    • 2018-09-19
    • 2019-12-05
    • 1970-01-01
    • 1970-01-01
    • 2021-04-19
    • 2019-05-10
    • 2020-10-02
    相关资源
    最近更新 更多