Post by fourgood » Wed Nov 23, 2011 11:24 pm

Is it possible to add orders, made with a specific e-mail address to a newly created account?
I have customers who have purchased several times, but only with the last order they created an account.

they used the same mail address for every order. how can i add these orders to the account?
Last edited by fourgood on Mon Dec 19, 2011 7:59 pm, edited 1 time in total.

Active Member

Posts

Joined
Wed Oct 20, 2010 9:49 pm

Post by fourgood » Thu Dec 01, 2011 3:34 pm

wonder that no one else came accross this issue?!

Active Member

Posts

Joined
Wed Oct 20, 2010 9:49 pm

Post by fourgood » Thu Dec 15, 2011 5:07 pm

*push*

no one with a solution?

Active Member

Posts

Joined
Wed Oct 20, 2010 9:49 pm

Post by uksitebuilder » Fri Dec 16, 2011 8:12 pm

Try the attached file.

Upload it to your store root then run it in a browser.

BACKUP your order table in your database first.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by fourgood » Mon Dec 19, 2011 7:31 pm

this is great so far.
any chance to get this to work without case sensitivity?

some clients wrote their addresse with different cases on different orders.

Active Member

Posts

Joined
Wed Oct 20, 2010 9:49 pm

Post by uksitebuilder » Mon Dec 19, 2011 7:38 pm

I made some adjustments to the script

Please re-download and run it again.

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by fourgood » Mon Dec 19, 2011 7:57 pm

You are the MAN!

Thanks a lot.

Active Member

Posts

Joined
Wed Oct 20, 2010 9:49 pm

Post by fourgood » Fri Nov 16, 2012 5:33 pm

sadly i was wrong as i said it was working.
Could you please take a look at it again?

Active Member

Posts

Joined
Wed Oct 20, 2010 9:49 pm

Post by fourgood » Mon Nov 19, 2012 6:34 pm

Code: Select all

<?php
require_once('config.php');
require_once(DIR_SYSTEM . 'startup.php');

// Registry
$registry = new Registry();

// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);

// Config
$config = new Config();
$registry->set('config', $config);

// Database 
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);

$query = $db->query("SELECT DISTINCT email, customer_id as cid FROM `" . DB_PREFIX . "order` WHERE customer_id > 0");

foreach ($query->rows as $row){
	$query2 = $db->query("UPDATE `" . DB_PREFIX . "order` SET customer_id = '". (int)$row['cid'] ."' WHERE LCASE(email) = '".strtolower($row['email'])."'");
}
	
echo 'done';
@unlink('runonce.php');
I think that

Code: Select all

WHERE customer_id > 0");
is the problem, because it selects all customers that have id greater than 0. But the customer with id = 0 are the ones that i want to assign an id to.

Active Member

Posts

Joined
Wed Oct 20, 2010 9:49 pm

Post by fourgood » Mon Nov 19, 2012 10:18 pm

I`ve solved it!

Code: Select all

$query = $db->query("SELECT DISTINCT email, customer_id as cid FROM `order` WHERE customer_id > 0");

foreach ($query->rows as $row){
   $query2 = $db->query("UPDATE `order` SET customer_id = '". (int)$row['cid'] ."' WHERE LCASE(email) = '".strtolower($row['email'])."' AND customer_id = 0");
}

Active Member

Posts

Joined
Wed Oct 20, 2010 9:49 pm
Who is online

Users browsing this forum: No registered users and 19 guests