I modified @Patrick's code to suit my needs to change Order Status to Processing instead, which might be useful to some, and can easily be modified eg. to Completed or Cancelled by editing the 3 parts where it says // Change to suit
add_action('woocommerce_cancel_unpaid_orders', 'update_onhold_orders');
function update_onhold_orders() {
$days_delay = 3; // Change to suit
$one_day = 24 * 60 * 60;
$today = strtotime( date('Y-m-d') );
// Get unpaid orders (X days old here)
$unpaid_orders = (array) wc_get_orders(array(
'orderby' => 'date',
'order' => 'DESC',
'limit' => -1,
'status' => 'on-hold',
'date_created' => '<' . ($today - ($days_delay * $one_day)),
));
if ( sizeof($unpaid_orders) > 0 ) {
$processing_text = __("Order status was automatically updated.", "woocommerce"); // Change to suit
// Loop through orders
foreach ( $unpaid_orders as $order ) {
$order->update_status( 'processing', $processing_text ); // Change to suit
}
}
}