And you can use the following function (NOT TESTED) to re-adjust them after you do the orders import.
function my_check_order_users() {
echo "
";
db_query("CREATE TABLE IF NOT EXISTS ?:orders_bkp LIKE ?:orders");
db_query("REPLACE ?:orders_bkp SELECT * FROM ?:orders");
printf("Backed up orders table to orders_bkp\n");
foreach(db_get_array(“SELECT o.order_id, o.email, o.user_id, u.user_id AS uid
LEFT JOIN ?:users AS u ON o.email=u.email
FROM ?:orders AS o”) as $order_data) {
if( empty($order_data[‘user_id’]) || $order_data[‘uid’] == '$order_data[‘user_id’] )
continue; // skip anonymous and valid
db_query("UPDATE ?:orders SET user_id=?i WHERE order_id=?i", $order_data['uid'], $order_data['order_id']);
printf("Reset user_id in order '%s' from '%d' to '%d'\n",
$order_data['order_id'], $order_data['user_id'], $order_data['uid']);
And you can use the following function (NOT TESTED) to re-adjust them after you do the orders import.
function my_check_order_users() {
echo "
";
db_query("CREATE TABLE IF NOT EXISTS ?:orders_bkp LIKE ?:orders");
db_query("REPLACE ?:orders_bkp SELECT * FROM ?:orders");
printf("Backed up orders table to orders_bkp\n");
foreach(db_get_array(“SELECT o.order_id, o.email, o.user_id, u.user_id AS uid
LEFT JOIN ?:users AS u ON o.email=u.email
FROM ?:orders AS o”) as $order_data) {
if( empty($order_data[‘user_id’]) || $order_data[‘uid’] == '$order_data[‘user_id’] )
continue; // skip anonymous and valid
db_query("UPDATE ?:orders SET user_id=?i WHERE order_id=?i", $order_data['uid'], $order_data['order_id']);
printf("Reset user_id in order '%s' from '%d' to '%d'\n",
$order_data['order_id'], $order_data['user_id'], $order_data['uid']);
If someone create a new account.. will show order history from other account
X create new account, and after that in Order from his account shows orders from Y user
In fact i don`t need and my customers too... we don`t need to keep orders history...even that... if we start from zero, orders history will show from other accounts
In my case was 2200 orders... so was not something that must have remained compulsory
As i said... export and import csv users don`t work with "user_number" row too... so if someone create a new account will be "user_2" other "user_3" and so on.... and that users will view in his account some orders from oldest user_number... from someonelse
All knows that my skills are limited, so :
I export xml file from oldest database from "cscart_users" table and import to the new database in same place
And now all my users are ok
Except usersgroup...was 100 users to one users group in my case so i make it manual
Orders looks good now... buy only look
If you click a product from users orders profile or admin panel... will direct to an wrong product ....obvious that product id dosen`t exist or replaced. But this is not bad for me...