The “Customer invoice/ Order details” WooCommerce email notification template is used manually by store owners when sending payment requests to customers. This email template is a perfect choice for sending pending payment reminders as well.
What we will be doing in this post is to use the Cusotmer invoice/ Order detail email template to send payment reminder notifications. To make it a bit smarter, we will make the reminder email triggered automatically when the order status transitioned to “pending payment”
Solution:Send Email for Pending Payment Status To Customers in WooCommerce
The code snippet will send a email notification to customers for pending payment order status.
add_action( 'woocommerce_order_status_pending', 'ts_send_pending_order_email', 10, 2 ); function ts_send_pending_order_email( $order_id, $order ) { if ( ! $order->needs_payment() ) return; WC()->payment_gateways(); WC()->shipping(); // Send customer invoice email WC()->mailer()->customer_invoice( $order ); // Add order note $order->add_order_note( __( 'Payment request automatically sent to customer.' ), false, true ); }
Output
Whenever the order status is changed to ‘pending payment’ the customer invoice email is triggered and will be sent to the customer email notifications as shown below.
Alternatively, if you want to keep the site admins in the loop, you can send processing order email to admin email notifications. This helps the admin to track the processing stage of the order
Hi, thanks for this solution. Does this also work for new orders that are automatically set to ‘pending payment’ at the checkout? For my product, customers need to download the invoice BEFORE paying (they send it to their finance department who then pays via bank transfer).
Hi Ruby,
Yes, this solution will also work for new orders that are automatically set to ‘pending payment’ at checkout. However, since you mentioned that the customer pays via the Bank Transfer payment method, the default order status will be set to ‘on-hold’. In this case, you’ll need to update the hook to woocommerce_order_status_on-hold instead.
Thanks Saranya, I will try that. I’m not too familiar with coding in WordPress, would you mind telling me where to insert that code component? Thank you!
Hi Ruby, You can place the code either in your child theme’s functions.php file or use a plugin like Code Snippets, which makes it easy to add custom code solutions. You can use the code below, which automatically sends an invoice email for orders set to ‘on-hold’ status. // Trigger the invoice email for orders that are set to on-hold after checkout add_action( 'woocommerce_order_status_on-hold', 'ts_send_invoice_email_for_on_hold_orders', 10, 1 ); function ts_send_invoice_email_for_on_hold_orders( $order_id ) { // Retrieve the order object using the order ID $order = wc_get_order( $order_id ); // Ensure the order is valid and has 'on-hold' status if ( $order… Read more »