Payment Complete Hooks
There are three different WooCommerce hooks after payment completed I would like to talk about.
woocommerce_pre_payment_complete
,woocommerce_payment_complete
,woocommerce_payment_complete_order_status_$status
;
All of those hooks are fired when an order is either paid or doesn’t require a payment (Cash on Delivery for example). They also apply for custom payment gateways.
If you need some custom coding related to WooCommerce payments, contact me.
woocommerce_pre_payment_complete
The first hook, woocommerce_pre_payment_complete
applies at the very beginning and doesn’t depend on order status.
add_action( 'woocommerce_pre_payment_complete', 'rudr_pre_complete' );
function rudr_pre_complete( $order_id ) {
$order = wc_get_order( $order_id );
// get the order data and do anything
}
- All the code snippets you see in this tutorial you can insert to your current theme
functions.php
file or create a plugin for that if your theme receives updates. - You can get a lot of information from the
$order
object, like$order->get_items()
to get order items or$order->get_payment_method()
to get a payment method slug or$order->get_user_id()
to get a customer ID.
woocommerce_payment_complete
The next one, woocommerce_payment_complete
will be fired only if an order has one of the following order status on-hold
, pending
, failed
, cancelled
, but please keep in mind that this list of statuses can also be filtered with woocommerce_valid_order_statuses_for_payment_complete
.
But before the hook applies, WooCommerce is going to change the order status either to processing
or completed
, which also can be filtered with woocommerce_payment_complete_order_status
.
add_action( 'woocommerce_payment_complete', 'rudr_complete' );
function rudr_complete( $order_id ) {
$order = wc_get_order( $order_id );
// do anything
}
woocommerce_payment_complete_order_status
And the last but not least, woocommerce_payment_complete_order_status_$status
will be fired for the rest of the order statuses.
add_action( 'woocommerce_payment_complete_order_status_processing', 'rudr_complete_for_status' );
add_action( 'woocommerce_payment_complete_order_status_completed', 'rudr_complete_for_status' );
function rudr_complete_for_status( $order_id ){
// do anything
}
When I say “do anything”, I do not actually mean absolutely anything, for example, if you would like to perform a redirect, it is better to be done with template_redirect
hook like I described here.
In some tutorials I also saw woocommerce_payment_complete_order_status
and woocommerce_order_status_completed
but I think their usage is less correct.
If you need some custom coding related to WooCommerce payments, contact me.

Misha Rudrastyh
Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.
Need some developer help? Contact me
Hey there,
I am from India. I am extremely thankful to you for all your tutorial regarding wordpress. I had a poor experience with wordpress and woocommerce but after getting help from your tutorial I am able to customize many things.
Thanks a lot
Keep up the good work man…
Thank you so much!
Hello Misha,
Thank you, but I think there is a problem in your tutorial.
It’s not :
woocommerce_payment_complete_order_status_$status
but :
woocommerce_order_status_$status
That is :
woocommerce_order_status_processing
woocommerce_order_status_on-hold
etc
Hey Walter,
Thank you for your comment, but here you’re not exactly right ;) Your hooks are OK, but they are not for the case when the payment is completed but for any situation when an order status is changed.
Hi. Thanks so much for the post.
Excuse the rookie question, but I’m having some difficulty finding what I’m looking for. How exactly would I filter a payment by status? I’m trying to trigger a webhook on successful payment completion.
Thank you kindly for any help.
Hi. I recommend
woocommerce_payment_complete
.