X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Trying to always use cust email as user ID.... (https://forum.x-cart.com/showthread.php?t=8650)

pipercub 07-28-2004 05:55 AM

Trying to always use cust email as user ID....
 
Many sites use the customer email address as their userID. Can anyone offer any insight as to how I can eliminate the 'Username' field on the registration form and ALWAYS have xcart use the customer email address?

Thanks,
Piper

xcell67 07-28-2004 06:59 AM

In 3.5.x, I tried fiddling with include/register.php and made $uname=$email, and commented out the username field in skin1/customer/main/register.tpl.

I thought it worked but when I tried changing the user id, an sql error occured. I remember reading a thread where someone had done it before, I hope that person pops up again on this thread.

pipercub 07-28-2004 09:10 AM

When you say change $uname=$email, what section in register.php did you change this in? I had searched register.php for a while before posting here, but I could not find the exact places to edit.

however, I did find the following bit of code that may resolve the SQL error.

In register.php, search for

Code:

#
# Add new person to customers table
#


Just below those lines, are the lines of code that query the DB.

In that chunk, change:
Code:

$uname
to
Code:

$email

Meanwhile, if you could give me some more detail on where you changed your code, we might be able to piece this together!

Thanks,
Piper

xcell67 07-28-2004 02:11 PM

Hi Piper,

First I modified this code for 3.5.6:

Code:

#
# Check for errors
#
        $uname_tmp=stripslashes($uname);
        if ( strcmp($uname_tmp, $uname) !=0)  {$error="Username ".$uname_tmp." is invalid! Please correct";  } else $error='';
        $smarty->assign("error",$error);

        $fillerror = (empty($uname) || !empty($error) || empty($passwd1) || empty($passwd2) || ($passwd1 != $passwd2) || empty($firstname) || empty($lastname) || empty($b_address) || empty($b_city) || (!empty($states) && empty($b_state)) || empty($b_country) || empty($b_zipcode) || empty($phone) || empty($email));

        $fillerror |= ($emailerror = !func_check_email($email));
       
        if (!(@$uerror || @$eerror || @$fillerror || @$error)) {


I took out $uname=tmp check and also the empty($unamee) in $fillerror.

so the code became this:

Code:

#
# Check for errors
#

        $smarty->assign("error",$error);

        $fillerror = (empty($passwd1) || empty($passwd2) || ($passwd1 != $passwd2) || empty($firstname) || empty($lastname) || empty($b_address) || empty($b_city) || (!empty($states) && empty($b_state)) || empty($b_country) || empty($b_zipcode) || empty($phone) || empty($email));

        $fillerror |= ($emailerror = !func_check_email($email));
       
        if (!(@$uerror || @$eerror || @$fillerror || @$error)) {


I did this so the cart wouldn't record an error if the username wasn't submitted.

Then I altered:

Code:

#
# Fields filled without errors. User registered successfully
#

                $crypted = text_crypt($passwd1);
                $s_address = trim($s_address);
                $s_city = trim($s_city);
                $s_zipcode = trim($s_zipcode);
            if (empty($s_address) && empty($s_city) && empty($s_zipcode)) {
                $s_state = $b_state;
                $s_country = $b_country;
            }
            if (empty($s_address)) $s_address = $b_address;
            if (empty($s_city)) $s_city = $b_city;
            if (empty($s_zipcode)) $s_zipcode = $b_zipcode;


At the bottom I entered

if (empty($uname)) $uname= $email;

I did this so the cart would automatically fill the empty username field with the email address.

I left the Add New/ and Update customer tables alone. Let me know if you figure it all out.

mizzlewillz 07-29-2004 05:57 PM

E-mail as Username
 
I've been wanting to do this for awhile. Thanks for the post.

I just tried your method in X-Cart 4.0.1 and it works... One question though.

How do you deal with someone that changes their e-mail. The way you have it, without touching other parts of register.php when you change your e-mail your old e-mail (username) stays the same.

General Question: If you were to use e-mail as your username, would it mess up the orders history for that particular person when they change their e-mail (username)?

-Mike

xcell67 07-30-2004 12:42 AM

Mike,
The problem you just mentioned is the reason why I don't use the mod for my own shops. I was hoping that someone else knew the solution, but no one wants to share :(

mizzlewillz 07-31-2004 12:58 PM

Just to add an additional comment. I was thinking of keeping the username, but also allow the Customer to login using either their e-mail or their username. One company that does that is textbookx.com which sells books. I think that way, the Customer can alter their e-mail all they want, and they don't have to worry about remembering a username.

This may seem ridiculous, but at the moment it is the only way I can think of for allowing the Customer to use their e-mail to login.

This would be a nice feature for the X-Cart team to put into their product. And to please everyone just have checkbox so you can turn the feature on and off, but that would probably cause a problem if you switch back and forth from the two methods.

Just my thoughts.

-Mike

thundernugs 08-31-2004 10:25 AM

http://forum.x-cart.com/viewtopic.php?t=12126


All times are GMT -8. The time now is 03:08 AM.

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