Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Send Email for Pending Payment Status To Customers in WooCommerce ?

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

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 );
add_action( 'woocommerce_new_order', 'ts_send_pending_order_email', 20, 2 );

function ts_send_pending_order_email( $order_id, $order ) {
    if ( ! $order instanceof WC_Order ) {
        $order = wc_get_order( $order_id );
    }

    if ( ! $order || $order->get_status() !== 'pending' || ! $order->needs_payment() ) {
        return;
    }

    // Get WooCommerce mailer and the Customer Invoice email object
    $mailer = WC()->mailer();
    $email  = $mailer->emails['WC_Email_Customer_Invoice'];

    // Trigger the email
    $email->trigger( $order_id );

    // Add an order note for reference
    $order->add_order_note( 'Payment reminder email sent automatically for Pending Payment order.' );
}


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.

How to Send Email for Pending Payment Status To Customers in WooCommerce ? - Tyche Softwares

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

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
8 Comments
Newest
Oldest
Inline Feedbacks
View all comments
Elton
3 months ago

Thanks for the article. It looks exactly like the function that I am looking for as there are several Payment Pending orders appeared in my webstore. I copy and pasted the function in the child theme’s functions.php. I tested the function with a new order created at the backend with the order status set to “pending payment”. I click create order but no reminder email is sent. Am I missing something? does the function required any plugin other than Woocommerce?

Elton
3 months ago
Reply to  Saranya

I am very happy to let you know the script works very well. Reminder email sent both for new Payment Pending order and order that switched into Payment Pending.

I hope it will catch a few leaked customers that have a order with a failed paypal transection (it happens a lot these few days)

Ruby
10 months ago

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).

Ruby
10 months ago
Reply to  Saranya

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!

8
0
Would love your thoughts, please comment.x
()
x
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible.

Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

By using our site, you acknowledge that you have read and understood our Privacy Policy and Terms & Conditions.