disable automatic order completion for downloable products
-
Hi,
Working on another Woo puzzle here. Orders consisting of downloadable products are being automatically set to “complete” status by Woo. Even though they’ve been paid for, these orders need to stay in “processing” status until they are manually closed by one of the staff. How do I do this?
After Googling and experimenting I have a block of code which I think ought to work but when I test the orders are still marked as “complete.” Any ideas on how to get this right?
Thank you.
/*prevent any orders from autocompleteing*/ add_filter( 'woocommerce_payment_complete_order_status', 'stop_autocomplete_virtual_orders', 10, 2 ); function stop_autocomplete_virtual_orders( $order_status, $order_id ) { $order = wc_get_order( $order_id ); if ('processing' == $order_status && ('on-hold' == $order->status || 'pending' == $order->status || 'failed' == $order->status)) { $virtual_order = ''; if ( count( $order->get_items() ) > 0 ) { foreach ( $order->get_items() as $item ) { if ( 'line_item' == $item['type'] ) { $_product = $order->get_product_from_item( $item ); if ( ! $_product->is_virtual() ) { $virtual_order = false; break; } else { $virtual_order = true; } } } } if ( $virtual_order ) { return 'processing'; } } return $order_status; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘disable automatic order completion for downloable products’ is closed to new replies.