如果订单状态为暂停,则禁用 WooCommerce 新订单电子邮件通知

问题描述:

有没有办法禁用新订单"?当订单状态为暂停"时发送给管理员的电子邮件通知?

Is there a way to disable the "New Order" e-mail notification sent to admin when the order status is "On hold"?

或者只为处理"启用它状态?

Or to enable it only for "processing" status?

我也尝试了不同的方法来接收新订单"仅在状态为正在处理"时发送电子邮件,没有成功.

I also tried different things to receive the "New Order" email only when the status is "Processing", without success.

任何帮助.

更新

禁用新订单"当订单状态为暂停"时发送给管理员的电子邮件通知,请使用:

To disable "New Order" e-mail notification sent to admin when the order status is "on-hold", use:

add_filter( 'woocommerce_email_recipient_new_order', 'disable_new_order_for_on_hold_order_status', 10, 2 );
function disable_new_order_for_on_hold_order_status( $recipient, $order = false ) {
    if ( ! $order || ! is_a( $order, 'WC_Order' ) ) 
        return $recipient;

    return $order->get_status() === 'on-hold' ? '' : $recipient;
}


启用新订单"发送给管理员的电子邮件通知仅在订单状态为正在处理"时替换上述功能:

return = $order->get_status() === 'on-hold' ? '' : $recipient;

具有以下内容:

return = $order->get_status() === 'processing' ? $recipient : '';


代码位于活动子主题(或活动主题)的functions.php 文件中.经测试有效.


Code goes in functions.php file of the active child theme (or active theme). Tested and works.