Here is a custom function hooked in woocommerce_thankyou
action hook, that will change the order status if this order has a status "on-hold" and if it has any backorder products in it.
You will have to set in the function the desired new status slug change.
Here is that custom function (code is well commented):
add_action( 'woocommerce_thankyou', 'change_paid_backorders_status', 10, 1 );
function change_paid_backorders_status( $order_id ) {
if ( ! $order_id )
return;
// HERE below set your new status SLUG for paid back orders
$new_status = 'completed';
// Get a an instance of order object
$order = wc_get_order( $order_id );
// ONLY for "on-hold" ORDERS Status
if ( ! $order->has_status('on-hold') )
return;
// Iterating through each item in the order
foreach ( $order->get_items() as $item ) {
// Get a an instance of product object related to the order item
$product = $item->get_product();
// Check if the product is on backorder
if( $product->is_on_backorder() ){
// Change this order status
$order->update_status($new_status);
break; // Stop the loop
}
}
}
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
The code is tested and works.