I am trying to send notification about new order only for "pending" order status and not "cash on delivery" payment method. But admin have receive duplicated mails when client choose cash on delivery payment, because Woocommerce update this order status from "pending" to "processed".
// New order notification only for "pending" order status and not "cash on delivery" payment method
add_action( 'woocommerce_checkout_order_processed', 'pending_new_order_notification', 10, 1 );
function pending_new_order_notification( $order_id ) {
// Get an instance of the WC_Order object
$order = wc_get_order( $order_id );
$payment_title = $order->get_payment_method_title();
// Only for "pending" order status and not Cash on delivery payment method
if( ! $order->has_status( 'pending' ) && ( $payment_title != 'cod' ) ) return;
// Get an instance of the WC_Email_New_Order object
$wc_email = WC()->mailer()->get_emails()['WC_Email_New_Order'];
## -- Customizing Heading, subject (and optionally add recipients) -- ##
// Change Subject
$wc_email->settings['subject'] = __('{site_title} - Новый заказ ({order_number}) - {order_date} ожидает оплату');
// Change Heading
$wc_email->settings['heading'] = __('Новый заказ');
$wc_email->settings['recipient'] .= ',name@email.com'; // Add email recipients (coma separated)
// Send "New Email" notification (to admin)
$wc_email->trigger( $order_id );
}