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

Change WooCommerce processing order email notification recipient to a custom address

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

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

此自定义函数挂在 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 文件或任何插件文件。

已测试并有效


To add the custom recipient to the customer email, you should use this instead (if needed):

$recipient .= ',name@example.com';