The “Customer invoice / Order details” WooCommerce email notification is often used for manually sending payment requests to customers – it’s not automatically triggered like other WooCommerce emails. You can access it from the individual order screen under the “Order Actions” section.
In certain cases, however, you’d want to make it automatic. And I don’t know why it’s not like that by default. So, let’s fix it: if you create a manual order from the backend, set it as pending, add some products to it and “Save”, the email notification will trigger on its own thanks to the snippet below. Enjoy!

PHP Snippet: Trigger “Customer invoice / Order details” WooCommerce Email Automatically
This WooCommerce PHP code snippet sends an automated email notification to the customer when their order status changes to “pending” and requires payment. Let’s break it down:
add_action( ‘woocommerce_order_status_pending’, ‘bbloomer_send_pending_order_email’, 9999, 2 );
- This line uses
add_action
to hook thebbloomer_send_pending_order_email
function to thewoocommerce_order_status_pending
action. This means the function will be executed whenever an order’s status changes to “pending”. - The
2
arguments indicate that the function accepts two arguments:$order_id
and$order
.
function bbloomer_send_pending_order_email( $order_id, $order ) {
- This function receives the
$order_id
and the$order
object as arguments.
if ( ! $order->needs_payment() ) return;
- This checks if the order requires payment using the
$order->needs_payment()
method. If it doesn’t (e.g., free order, order already paid), the function exits.
WC()->payment_gateways();
WC()->shipping();
WC()->mailer()->customer_invoice( $order );
- These three lines seem involve initializing WooCommerce components like payment gateways, shipping methods, and the mailer class, including the actual sending of the “customer_invoice” notification.
$order->add_order_note( __( ‘Payment request automatically sent to customer.’, ‘bbloomer’ ), false, true );
- This line adds a note to the order history stating that a payment request was automatically sent to the customer.
- The
__( 'Payment request automatically sent to customer.', 'bbloomer' )
part uses the WordPress translation function to ensure the note is displayed in the correct language based on the store’s settings. - The
false
argument prevents the note from being sent to the customer as an email notification. - The
true
argument marks the note as private, meaning it’s only visible to administrators.
/**
* @snippet Automatically Send Woo Customer Invoice Email
* @tutorial Get CustomizeWoo.com FREE
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 8
* @community Join https://businessbloomer.com/club/
*/
add_action( 'woocommerce_order_status_pending', 'bbloomer_send_pending_order_email', 9999, 2 );
function bbloomer_send_pending_order_email( $order_id, $order ) {
if ( ! $order->needs_payment() ) return;
WC()->payment_gateways();
WC()->shipping();
WC()->mailer()->customer_invoice( $order );
$order->add_order_note( __( 'Payment request automatically sent to customer.', 'bbloomer' ), false, true );
}
Hi,
I have reviewed your code, but I noticed an issue. When the default order status is set to “pending payment” and I try to manually send an email using the “Send order details to customer” option on the right side of the screen, the following hook no longer works:
It seems this hook is not being triggered anymore. I even tried adding echo “Hello”; exit; to debug, but it’s not being called.
Could you please check if there’s a different hook we need to use for this functionality?
Please check this screenshot how i am creating an order manually.
https://prnt.sc/4bE6wgX0p27G
Thank you!
Hello Ahir! The function is triggered when the status goes from “anything” to “pending“. If it’s created with “pending” status, and it doesn’t transition to it, it won’t trigger. Does this help?
This code isn’t working for us, we installed it a year ago and just checked 300 re ent pending orders and none of them got an email and there are no order noted on any of the orders…?
This triggers when the order status goes from *whatever* to pending. Is that the case?
This may have changed but currently ‘woocommerce_order_status_pending’ is not called when an order is created at checkout as “pending’ is the default status.
That could be, my aim was to target manual orders to be honest. When does the order go/stay into pending on the normal checkout?
Orders are automatically ‘pending payment’ at checkout as their default status. I think this might be why your code doesn’t work for checkout orders. For my product, customers need the invoice first in order to pay (they have to send it to their finance department who then pays manually), so I’m trying to find a way to automatically send an invoice with the ‘Pending order’ email. Do you have any ideas? Thanks! 🙂
Gotcha. After which “event” do you need to trigger the email?