Hello @caoba,
I hope you are well
Thank you @shakoor99 fot your suggestion on this, we appreciate it!
Our steps for the migration would be as follows:
Perform the following procedure first on your staging site; if everything goes well, then on your live site:
1- Make a backup of the database.
2- Create the new statuses with our plugin (the new plugin).
3- Manually disable the email configuration that were generated for each new custom status (created in step 2) to prevent e-mails from being sent in the migration process ==> WooCommerce > Settings > Emails
4- Use the following script to migrate the statuses – it takes all orders based on the old status and changes their statuses to the new one:
/**
* Migrate WooCommerce order statuses - Maximum for 1000 orders to be migrated
*
* This script will change the status of all orders
* that match the indicated status (old status) to a new status (new status).
*
* Script created by Bright Plugins
*/
if( !function_exists( 'bp_migrate_order_statuses' ) ) {
function bp_migrate_order_statuses($old_status, $new_status) {
// Get all orders with the old status
$orders = wc_get_orders(array(
'status' => $old_status,
'limit' => -1, // Retrieve all orders
));
foreach ($orders as $order) {
// Change the status
$order->set_status($new_status);
$order->save();
}
echo '<pre>';var_dump( 'Migration attempt completed for: ' . $new_status );'</pre>';die;
}
add_action('wp_footer', function(){
if (!is_user_logged_in() || !current_user_can('manage_options')) {
return; // Exit if not an admin
}
/**
* Put here the old status and the new status,
*
* $old_status => for the old status
* $new_status => for the new status you want the orders to have.
*/
$old_status = '';
$new_status = '';
/**
* @param string $old_status The slug of the old status.
* @param string $new_status The slug of the new status.
*/
bp_migrate_order_statuses( $old_status, $new_status );
});
}
5- Uninstall the old plugin.
6- Verification of the orders.
7- Done.
I hope this can help you !
– Best Regards