Automatically Change WooCommerce Orders to Completed for Virtual and Digital Products
Move paid WooCommerce orders to Completed automatically when every purchased item is virtual and downloadable.
WooCommerce normally moves a paid order to Processing. For products that require no shipment, such as downloads, licenses, or online consultations, the store may want to mark the order Completed immediately.
Use this snippet only when an order containing virtual products does not need a manual fulfillment step. Add it to a child theme’s functions.php file or a code snippets plugin.
The snippet
add_filter( 'woocommerce_payment_complete_order_status', function( $status, $order_id, $order ) { if ( ! $order instanceof WC_Order ) { return $status; }
// Keep unpaid, failed, or cancelled orders out of the automatic transition. if ( ! $order->is_paid() ) { return $status; }
$all_items_are_virtual = true;
foreach ( $order->get_items( 'line_item' ) as $item ) { $product = $item->get_product();
if ( ! $product || ! $product->is_virtual() ) { $all_items_are_virtual = false; break; } }
return $all_items_are_virtual ? 'completed' : $status;}, 10, 3 );Virtual is not the same as downloadable
The code checks is_virtual(), which means the product does not require shipping. A virtual product can still require manual work, so use is_downloadable() instead if only downloadable products should auto-complete:
if ( ! $product || ! $product->is_virtual() || ! $product->is_downloadable() ) { $all_items_are_virtual = false; break;}The condition is evaluated when payment completes, not when the customer merely submits the checkout. This keeps failed and pending payments from being marked Completed. If a gateway completes payment asynchronously, the transition will occur when that gateway calls WooCommerce’s payment-complete flow.
Mixed carts remain Processing
An order containing one physical product and one virtual product stays at the normal status because every line item must pass the rule. That is intentional: a mixed order still needs shipment and fulfillment tracking.
WooCommerce’s virtual and downloadable product documentation explains the difference between products that need no shipping and products that provide downloadable files. For a different order rule, see how to save custom checkout data to order meta and emails.