WooCommerce Automatically Set the Complete Order Status

Automatically set the order status to completed in WooCommerce

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About this Solution

If you’d like to bypass the on-hold order status which either WooCommerce or the payment gateway the customer uses automatically sets on orders, and make it the Completed order status instead, then this guide is for you. Typically, store owners wont have the Order on-hold email active. Instead, they will have the Processing order or Completed order. It’s not usual that customers receive an email to tell them their order is on hold, so this solution resolves that. This solution also reduces admin overhead because your staff wont have to login and update each order with the Completed order status – it’s done automatically when the thank you page is triggered.

				
					/**
* Snippet Name:     Automatically set the completed order status in WooCommerce.
* Snippet Author:   ecommercehints.com
*/

function custom_woocommerce_auto_complete_order( $order_id ) {
    if ( ! $order_id ) {
        return;
    }

    $order = wc_get_order( $order_id );
    if( 'on-hold'== $order->get_status() ) {
        $order->update_status( 'completed' );
    }
}
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_order' );
				
			

Snippet Benefits

  • Trigger the Order Completed email in WooCommerce by automatically updating the Order Status from On-hold to Completed when an order is created by the customer.
  • Reduces staff overhead having to manually edit the order status of new orders.
  • Receive finds quicker from payment gateways as the order is automatically set to complete.
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

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

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers