How to Auto complete paid orders in Woocommerce

In WooCommerce, you can automatically mark orders as “completed” once they’ve been paid for. This can be useful for digital products or services that don’t require manual processing.

To set up automatic order completion for paid orders in WooCommerce, you can use a hook provided by WooCommerce called woocommerce_payment_complete. You’ll need to add some custom code to your theme’s functions.php file or use a custom plugin.

Here’s an example of how you can do this:

add_action( ‘woocommerce_payment_complete’, ‘auto_complete_paid_orders’ );

function auto_complete_paid_orders( $order_id ) {
// Get the order object
$order = wc_get_order( $order_id );

// Only auto-complete orders with “processing” status
if ( $order->get_status() === ‘processing’ ) {
$order->update_status( ‘completed’ );

This code adds an action hook that triggers when a payment is marked as complete (woocommerce_payment_complete). It then retrieves the order object using the $order_id parameter passed to the hook.

The function auto_complete_paid_orders checks if the order status is “processing” (you can adjust this condition based on your needs). If the condition is met, it updates the order status to “completed”.

Make sure to test this functionality thoroughly on a staging or development site before implementing it on a live site to ensure it behaves as expected with your specific setup and workflow.