Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Complete paid orders of virtual products

Paid orders that contain only virtual products (services, memberships, tickets) go straight to Completed instead of waiting in Processing.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Needs WooCommerce
  • Tested with WordPress 7.1, WooCommerce 11.1
PHP
<?php

add_filter(
	'woocommerce_payment_complete_order_status',
	static function ( $status, $order_id, $order = null ) {
		$order = $order instanceof WC_Order ? $order : wc_get_order( $order_id );
		if ( 'processing' !== $status || ! $order ) {
			return $status;
		}
		foreach ( $order->get_items() as $item ) {
			$product = $item instanceof WC_Order_Item_Product ? $item->get_product() : null;
			if ( ! $product || ! $product->is_virtual() ) {
				return $status;
			}
		}
		return 'completed';
	},
	10,
	3
);

Good to know

Only for payments that complete online (cards, PayPal…). Bank transfer and cash on delivery orders are left as they are.

In these packs

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.