By default, the status of an order on WooCommerce will automatically change from “pending” to “processing” after a customer places an order and the payment is successful.

As the store owner or administrator, you will normally then need to manually mark the order as ‚ÄúComplete‚ÄĚ. This is usually done when the order is shipped. However, in some cases, you may want the order to proceed to the ‚ÄúComplete‚ÄĚ status immediately. For example, if you offer a digital product or a membership service or maybe the shipment process is automated.

With WooCommerce, you can automatically “complete” orders without needing to do anything manually.

This reduces the headache of manually completing each paid order.

In this blog, we will show you how to set up automatic completion of orders using a code snippet.

Let’s dive right in.

Here’s the code snippet you need to add to your site in order to complete orders automatically.

/**
* Auto Complete all WooCommerce orders.
*/
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
function custom_woocommerce_auto_complete_order( $order_id ) {
if ( ! $order_id ) {
return;
}

$order = wc_get_order( $order_id );
$order->update_status( 'completed' );
}

Note: You should create a child theme to use this custom code (or any customisation code). So if you are not already doing so, please switch to a child theme. Then add the custom code to the child theme’s functions.php using the instructions below:

Step-by-step process to set up automatic completion of orders on your WooCommerce store.

Here’s an example order placed by a customer.

order received 1
Oder number 4319 received

Go to WooCommerce> Orders to check the status of the order.

You will note that the order status will be “processing”. This confirms the order has been successfully placed and payment has been received. But the order has not yet been shipped or “completed”.

Processing - order status
Order status is Processing

Now we are going to change the status automatically to Complete for the orders we will receive in the future, using the code snippet at the beginning of the blog.

Log into your WooCommerce dashboard

  1. Copy the above code snippet
  2. From the left panel of the dashboard, go to Appearance>Theme Editor> functions.php.Add code to fuctions php
  3. Add the code to the file and save.Edit the code
    Note: Once you have added this Snippet you will probably want to turn off the emails for the Processing status, otherwise, the customer may receive an ‚ÄúOrder Processing‚ÄĚ and ‚ÄúOrder Complete‚ÄĚ in quick succession. You can turn these off by going to WooCommerce -> Settings -> Emails.

After enabling automatic order completion, let’s see what happens when we receive the next order 4320.

order received
Order 4320 received

Now, let’s take a look at the status of this order on the dashboard.

Order status complete
Order status: Completed

Now you have learnt how to automatically complete orders on WooCommerce.

Want to experience what trusted eCommerce support feels like? Contact us now