Are you using WooCommerce on your store and looking to do something after a successful payment on your store? The WooCommerce hook “woocommerce_payment_complete” might be helpful to you.

Below is the usage of the hook:

/**
 * Do something after successful payment.
 * 
 * @param  int $order_id
 * 
 * @return Return.
 */
function sa_wc_payment_complete( $order_id ) {
	
	// Do something.

	return;
}

add_action( 'woocommerce_payment_complete', 'sa_wc_payment_complete'  );

With the parameter, $order_id you can get almost all the information you might need. You can get the complete order object from $order_id . You might also want to get the User object. Here’s how you can get it.

$order = wc_get_order( $order_id );
$user = $order->get_user();

Here’s the complete print of $order object. See the “Details” section.

One of the practical use cases of this hook can be to make the “processing” payment status “complete”. In case you’re wondering why WooCommerce makes the status “processing”, you can check the details on WooCommerce processing status, and how to automatically make them “complete”.


Heads up! The hook “woocommerce_payment_complete” doesn’t guarantee successful payment. The hook will be fired on other statuses like “oh-hold”, “canceled”, “failed” etc.

In case you’re also looking for a WooCommerce hook after product added to cart?

WooCommerce hook after successful payment 🙂
Tagged on:

Sanjeev Aryal

Don't bury your thoughts, put your vision into reality ~ Bob Marley.

Leave a Reply

Your email address will not be published. Required fields are marked *