How to auto-complete orders in WooCommerce

Do you want to automatically complete orders in WooCommerce?

You can use my free plugin RIACO Autocomplete Orders for WooCommerce, or you can add some code to your child theme’s functions.php file.

Here’s how.

Using a Plugin

There are several plugins available to handle automatic order completion.

I developed RIACO Autocomplete Orders for WooCommerce, which has a free basic version.

The plugin automates order completion based on:

  • the order status (e.g., “Processing” or “On hold”),
  • the product type (virtual, downloadable, simple, variable, grouped, external).

Custom order statuses and custom product types are also supported.

Here’s how to use it:

  1. Install and activate the plugin, then go to WooCommerce > Settings > Autocomplete Orders.
  2. You’ll see a new tab added to WooCommerce’s native settings panel.
RIACO Autocomplete Orders for WooCommerce

I’ve created a detailed page where I explain all the plugin settings, but here’s a summary:

  • Select Enable Autocomplete to activate the plugin.
  • Add to Trigger Status the WooCommerce order statuses you want to be completed automatically.
    • You can add more than one.
    • Only orders with one of the selected statuses will be automatically completed, provided all other conditions are met.
  • Add to Product Types to Autocomplete the WooCommerce product types you want to be autocompleted.
    • You can add more than one.
  • Save.

Now all orders that match the conditions you selected will be completed automatically.

Using a Code Snippet

To change WooCommerce’s default order behavior, we can use the woocommerce_order_status_changed action to run our code whenever an order changes status.

Insert this code in your child theme’s functions.php:

add_action( 
    'woocommerce_order_status_changed', 
    'my_maybe_autocomplete_order', 
    20, 
    4 
);

function my_maybe_autocomplete_order( $order_id, $old_status, $new_status, $order ) {
    
    // Condition: only complete if the new status is "processing"
    if ( $new_status !== 'processing' ) {
        return;
    }

    // Get order items
    $items = $order->get_items();
    $only_virtual = true;

    foreach ( $items as $item ) {
        $product = $item->get_product();
        
        // If any product is not virtual => do not autocomplete
        if ( ! $product || ! $product->is_virtual() ) {
            $only_virtual = false;
            break;
        }
    }

    // If all products are virtual, change status to "completed"
    if ( $only_virtual ) {
        $order->update_status( 'completed', __( 'Order automatically completed because it contains only virtual products.', 'my-textdomain' ) );
    }
}

This code automatically completes the order only if the new status is “processing”.

It then checks the products inside the order, and if all are of type Virtual, it proceeds with automatic completion using WooCommerce’s native function:

$order->update_status( 'completed', ..., ... );

You can add or modify order statuses by changing the condition:

$new_status !== 'processing'

You can also add or modify other product types in the condition:

! $product->is_virtual()

Why Automate?

Why is it useful and convenient to automate order completion?

  • Less manual work: perfect for stores selling digital products. You save time and money.
  • Better user experience: right after payment, the user will see their order marked as completed and gain instant access to their files.

More posts