Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Change Order Status for Downloadable Products in WooCommerce?

All virtual and downloaded products straightway goes to completed status once payment is done. This is the default behavior set by WooCommerce to process digital products. But if you wish to set some additional processing steps you may use a plugin or a custom code to achieve this.

Solution: Change Order Status for Downloadable Products in WooCommerce

The code snippet below will help you to add an order status ‘processing’ if the order contains a downloadable product. In short, we are adding an additional workflow ‘processing’ rather than immediately marking it as ‘completed’ for downloadable products.

add_action( 'woocommerce_order_status_changed', 'ts_change_status_downloads', 1  );

function ts_change_status_downloads( $order_id ){

	// initiate the order
	$order = wc_get_order( $order_id );

	// let's suppose by default that all products are downloadable
	$only_downloadable_products = true;
	
	// loop through all products
	foreach ($order->get_items() as $product_id => $product_data) {

		// WC_Product object
		$product = $product_data->get_product();
		if ( !$product->is_downloadable() ) { // not downloadable
			$only_downloadable_products = false; 
			break;
		}
	}

	if( $only_downloadable_products == true ) {
		$order->update_status('processing');
	}
	
}

Output

When an order is placed that contains downloadable products the order status immediately goes to ‘processing’ regardless of the default assigned status ‘completed’.

Change Order Status for Downloadable Products in WooCommerce

Similarly, you can also set the status based on parameters such as product categories, tags and many more. You can check out here on how to customize WooCommerce order status based on Product Categories.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x