Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stuartduff/3209f2e7f52d3086cf909dacb97becef to your computer and use it in GitHub Desktop.
Save stuartduff/3209f2e7f52d3086cf909dacb97becef to your computer and use it in GitHub Desktop.
This code will send an email to the WooCommerce store owner for Pending Payment orders
// New order notification only for "Pending" Order status
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;
// 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} - New customer Pending order ({order_number}) - {order_date}');
// Change Heading
$wc_email->settings['heading'] = __('New customer Pending Order');
// $wc_email->settings['recipient'] .= ',name@email.com'; // Add email recipients (coma separated)
// Send "New Email" notification (to admin)
$wc_email->trigger( $order_id );
}
@RavanH
Copy link

RavanH commented Jan 20, 2023

Thanks @stuartduff !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment