首页 文章

将WooCommerce处理订单电子邮件通知收件人更改为自定义地址

提问于
浏览
0

当WooCommerce中的订单状态从 pending 设置为 processing 时,我可以向我的客户发送电子邮件 . 但我只需要向自定义电子邮件地址发送电子邮件,而不是客户默认地址 .

是否有 functions.php 文件的钩子或过滤器?

enter image description here

1 回答

  • 1

    这个自定义函数挂钩在 woocommerce_email_recipient_customer_processing_order 过滤器钩子中,将完成这项工作(在其中设置您的替换电子邮件):

    add_filter( 'woocommerce_email_recipient_customer_processing_order', 'processing_order_replacement_email_recipient', 10, 2 );
    function processing_order_replacement_email_recipient( $recipient, $order ) {
        if ( ! is_a( $order, 'WC_Order' ) ) return $recipient;
    
        // Set HERE your replacement recipient email(s)… (If multiple, separate them by a coma)
        $recipient = 'name@example.com';
        return $recipient;
    }
    

    代码放在活动子主题(或主题)的function.php文件中,或者放在任何插件文件中 .

    经过测试和工作


    要将自定义收件人添加到客户电子邮件中,您应该使用它(如果需要):$ recipient . =',name @ example.com';

相关问题