/**
* Add customer email recipient for admin New Order emails if a order placed with Checks
*
* @param string $recipient a comma-separated string of email recipients (will turn into an array after this filter!)
* @param \WC_Order $order the order object for which the email is sent
*
* @return string $recipient the updated list of email recipients
*/
function hush_conditional_email_recipient( $recipient, $order ) {
// Bail on WC settings pages
$page = $_GET[ 'page' ] = isset( $_GET[ 'page' ] ) ? $_GET[ 'page' ] : '';
if ( 'wc-settings' === $page ) {
return $recipient;
}
// just in case
if ( ! $order instanceof WC_Order ) {
return $recipient;
}
//-- If paid with Cheque, change status to pending payment.
if ( in_array( $order->get_payment_method(), array( 'cheque' ) ) ) {
$recipient .= ', ' . $order->get_billing_email();
return $recipient;
}
return $recipient;
}
//-- Add customer email recipient for admin New Order emails if a order placed with Checks
add_filter( 'woocommerce_email_recipient_new_order', 'hush_conditional_email_recipient', 10, 2 );