Reputation: 11
I am trying to make Email notification that goes to the admin and also to customer for a pending order.
I am using "Send an Email notification to the admin for pending order status in WooCommerce" answer code, that sends the email only to the admin and I want to sent it also to the customer.
Any help is appreciated.
Upvotes: 1
Views: 607
Reputation: 254362
You need to add also an email notification to customer as "On Hold" for example, like:
add_action( 'woocommerce_checkout_order_processed', 'pending_new_order_notification', 20, 1 );
function pending_new_order_notification( $order_id ) {
// Get an instance of the WC_Order object
$order = wc_get_order( $order_id );
// Only for "pending" order status
if( ! $order->has_status( 'pending' ) ) return;
// Send "New Email" notification (to admin)
WC()->mailer()->get_emails()['WC_Email_New_Order']->trigger( $order_id );
// Send "On Hold Email" notification (to customer)
WC()->mailer()->get_emails()['WC_Email_Customer_On_Hold_Order']->trigger( $order_id );
}
Code goes in functions.php file of the active child theme (or active theme). Tested and works.
Since WooCommerce 5+: Allow re-sending New Order Notification in WooCommerce 5+
Upvotes: 1