X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Use E-mail address instead of username 3.5.x & 4.0 (https://forum.x-cart.com/showthread.php?t=8809)

Speedmaster 04-01-2005 06:12 PM

x-light,

It looks like this mod still allows anonymous checkout? How can a returning customer checkout anonymously if the email field is unique?

Also, let me know if I am understanding this correctly. When a customer enters his/her info during checkout, your mod creates the customer if the email is unique, but deletes it if it finds out the customer is checking out anonymously?

One more thing, our store has been live for a while so we have some customers. The last time I checked, we have up to 800 customers who have anonymously checked out more than once (in other words, we have a lot of duplicate emails). How can we remove or handle those?

Thanks.

x-light 04-03-2005 12:38 PM

Hi Speedmaster,

Quote:

It looks like this mod still allows anonymous checkout? How can a returning customer checkout anonymously if the email field is unique?

That's a good question. This relates to your second question. When a customer checks out anonymously, the mod will check to see if a his/her email exist in the customers table. If it does exist and it belongs to an anonymous user, it will first delete that specific record and create a new one with that email. However, if the email exist and it belongs to an registered user, the mod will set the eerror and an duplicate email error will be returned to the user. This should be safe since anonymous users only log in to place an order once and if they do place an order, a seperate order record is placed in the orders table.

Quote:

Also, let me know if I am understanding this correctly. When a customer enters his/her info during checkout, your mod creates the customer if the email is unique, but deletes it if it finds out the customer is checking out anonymously?

Actually, it only creates the record when the following is true as shown in the above answer.

Quote:

One more thing, our store has been live for a while so we have some customers. The last time I checked, we have up to 800 customers who have anonymously checked out more than once (in other words, we have a lot of duplicate emails). How can we remove or handle those?

Well I don't know exaclty what you want to do with this. However, if I understand you correctly, it sounds like you want to remove records that has duplicate emails. I think what you may need is a custom script which access the customers table outside x-cart and do some logic checking. However, since you are running a live store, I would definitely backup your entire database just in case if the script deletes the wrong records. You can whip up a script which retreives all anonymous customers from the customer table do perform the following logic:

1. store each records with with same email in an list of arrays
2. compare to see if the first_login time is newer than the previous one if exist if, so keep this record, else delete this record (this ensures that the emails should be most recent after all duplicate is removed)

That should be it, after you run a script which perform these logic, your customer table should have no duplicate emails along with the latest first_login time for each of them. Hope this helps.

~x-light
[/code]

Grumpy 04-03-2005 06:34 PM

Email Address
 
OK, so what happens when the user changes their email address? I think a user name is a far simpler approach. Also easier to log in with.

Speedmaster 04-04-2005 11:49 AM

x-light,

Thanks for the info. I'm going to go work on this now.

phil_ 04-22-2005 06:07 AM

Did anyone get the x-light code implemented for the 3.5x branch? I would really like this mod, but as soon as I changed the code to use 'func_query_first cell' it seemes to fall down. :(

Lingerieblowout 04-22-2005 11:05 AM

Has anyone done this mod for 3.4.x ??

usiripakdi 04-22-2005 09:12 PM

Has anyone modify it in 4.13? Any problems?
I think register.php in /include is a bit different.

x-light 04-23-2005 12:38 AM

Hi all,

I am glad to hear some feedbacks about this mod.

Quote:

Did anyone get the x-light code implemented for the 3.5x branch? I would really like this mod, but as soon as I changed the code to use 'func_query_first cell' it seemes to fall down.

Code:

Has anyone done this mod for 3.4.x ??

hey guys, unfortunately I don't have v3.4.x or 3.5x release so I would not know how much work is required to make it compatible. I only have v4.0.12 and v4.0.13 release. Also, I have been working on other mods to customize my store so I won't have too much time in looking at this. Hopefully, someone out there with your versions finds this mod useful and make the proper modifications. Good luck.

Quote:

Has anyone modify it in 4.13? Any problems?
I think register.php in /include is a bit different.

hello usiripakdi, actually, I switched from v4.0.12 to v4.0.13 so I have the updated code. There isn't much difference between these 2 versions as far as the mod is concerned. Here is the updated code.

------------------------------------
include/register.php v3

Code:

# mod1
# find original code snippet
#
# User registration info passed to register.php via POST method
#
        $existing_user = func_query_first("select password, email from $sql_tbl[customers] where login='$uname'");
        if (empty($existing_user)) {
                $existing_user = func_query_first("SELECT login FROM $sql_tbl[orders] WHERE login='$uname'");
    }
# end original code snippet

# replace modified code snippet
#
# User registration info passed to register.php via POST method
#
        $existing_user = func_query_first("select password, email from $sql_tbl[customers] where login='$uname'");
        if (empty($existing_user)) {
                $existing_user = func_query_first("SELECT login FROM $sql_tbl[orders] WHERE login='$uname'");

# mod.use.email.rather.username
# generate unique id number as username since email is used as unique key in customers and order table
# only for non-anonymous users
        if( !$anonymous_user ){
            for( $i=0; $i<3; $i++ ){
                $u_tmp = uniqid(rand());
                if( $login != $u_tmp )
                    break;
            }
            $uname = $u_tmp;
        }
    }
# end modified code snippet


# mod2
# find original code snippet
        if (!(@$uerror || @$eerror || @$fillerror || @$error)) {
#
# Fields filled without errors. User registered successfully
#
                $crypted = addslashes(text_crypt($passwd1));
# end original code snippet

# replace modified code snippet
# mod.use.email.rather.username
    if(!$fillerror) {
        # check if email already exist in customers table
        $email = strtolower($email);
        if( $email == func_query_first_cell("select email from $sql_tbl[customers] where email='$email'")) {
                # duplicate email not allowed
                $eerror = true;
        }

        # exception checks to this rule
        if( $mode != "update") {
            # check if this is anonymous registration during checkout
            if( $eerror && func_query_first_cell("select status from $sql_tbl[customers] where email='$email' and usertype='C'") == 'A' ) {
                # delete this record since the user is anonymous requesting the same email
                # we can't assume that the email belongs to the user, but at least this way
                # the original user can use his/her same email to register again anonymously during another checkout
                # if an anonymous user already placed an order with this email, it will not effect the orders table
                # since it is a seperate record
                # note, if the user is already registered, we will never allow to automatically delete the registered user's record
                db_query("DELETE FROM $sql_tbl[customers] WHERE login LIKE 'anonymous%' AND email='$email' and usertype='C' AND status='A'");
                # this is not an error since we have deleted this record
                $eerror = false;
            }
        }
        else {
            if( $email == func_query_first_cell("select email from $sql_tbl[customers] where login='$login' and email='$email'")) {
                # email match, user did not change email
                $eupdate = false;
                # this is not an error since the existing email belong to this user
                $eerror = false;
            }
            else {
                # email does not match, see if new requested email is taken
                if( !$eerror )
                    $eupdate = true;
            }
        }
        } // mod.use.email.rather.username

        if (!(@$uerror || @$eerror || @$fillerror || @$error)) {
#
# Fields filled without errors. User registered successfully
#
                $crypted = addslashes(text_crypt($passwd1));
# end modified code snippet

# mod3
# find original code snippet
#
# Update/Insert user info
#

                if ($mode=="update") {
                        $intershipper_recalc = "Y";
                db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', email='$email', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id' WHERE login='$login' AND usertype='$login_type'");
# end original code snippet

# replace modified code snippet
#
# Update/Insert user info
#

                if ($mode=="update") {
                        $intershipper_recalc = "Y";

# mod.use.email.rather.username
# update email only if eupdate is true
            if( !$eupdate )
                db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id' WHERE login='$login' AND usertype='$login_type'");
            else
                db_query("UPDATE $sql_tbl[customers] SET password='$crypted', password_hint='$password_hint', password_hint_answer='$password_hint_answer', title='$title', firstname='$firstname', lastname='$lastname', company='$company', b_address='".$b_address."\n".$b_address_2."', b_city='$b_city', b_county='".(@$b_county)."', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_address='".$s_address."\n".$s_address_2."', s_city='$s_city', s_county='".(@$s_county)."', s_state='$s_state', s_country='$s_country', s_zipcode='$s_zipcode', phone='$phone', email='$email', fax='$fax', url='$url', card_name='$card_name', card_type='$card_type', card_number='".addslashes(text_crypt($card_number))."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password', parent = '$parent', pending_plan_id = '$pending_plan_id' WHERE login='$login' AND usertype='$login_type'");
# end modified code snippet


~x-light

usiripakdi 04-23-2005 01:54 AM

Thanks X-light =D>

2019 06-30-2005 11:40 PM

passing to 4.0.14 any code changes? :(
updated and all my custom work fly away closed to shop to fix them out :(

for example register.php in root is different on 4.0.14 :(

x-light hear my cry


All times are GMT -8. The time now is 12:21 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.