Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Use E-mail address instead of username 3.5.x & 4.0
 
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features
 
Thread Tools Search this Thread
  #11  
Old 03-14-2005, 11:47 PM
 
issay issay is offline
 

Advanced Member
  
Join Date: Mar 2003
Posts: 59
 

Default

In this case, when customers register, can they still specify a username? Can we make the customers type the email address only since having username and email maybe a bit confusing.
__________________
Pro 4.3
Linux/Apache
Reply With Quote
  #12  
Old 03-15-2005, 07:34 AM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default

Yes, but you'll need to modify include/register.php to remove any username/password validation checks, along with removing the input fields from the register form.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #13  
Old 03-16-2005, 01:38 AM
 
mrbiggles mrbiggles is offline
 

Senior Member
  
Join Date: Jan 2005
Location: Adelaide , South Australia
Posts: 107
 

Default

Hello
Just installed this on 4.11 and it works very nicely, thankyou.
__________________
www.creydall.com
X-Cart version 4.0.11
PHP 4.3.9 MySQL 4.0.22
Apache/1.3.33
Perl 5.008004
Adam
Adelaide South Australia
Reply With Quote
  #14  
Old 03-22-2005, 04:36 PM
 
x-light x-light is offline
 

Member
  
Join Date: Mar 2005
Posts: 29
 

Default use email rather username

Hello all,

As I am new to this forum, but not new to development work, I would like to share a token of my appreciation for all the great custom mods everyone has been sharing by contributing to a rather complete solution for this topic. Btw, thanks Boomer for starting this important topic. I have tested it with 4.0.12 only and so far everything seem to work well according to the features I have outlined below.

For security purpose, I will only post code here in this forum and it's rather long so bear with me. I will be busy the next couple days, but will try my best to answer to questions that you may have regarding to this mod. Enjoy

~x-light

-------------------------------------------------------------------------------------
Description: This mod allow all users customers, admins to use their email to register for an account and login instead of username. It modifies the register process to automatically generate an unique Id for the username during the registration process. If the user is anonymous, it resorts back to the default "anonymous+1"username X-Cart uses.

Key feature:
* checks for duplicate email during user registration or user profile updates and return appropriate errors.
* The user can also change their email at any time as long as their email has no duplicates.
* To avoid confusion, customers can only login using their email.
* If the user is an administrator, he/she can login using either their username or email.
* During an anonymous checkout, anonymous users can use same email to register again since register will drop previous anonymous user's record with the same email. This should be ok since the orders table is not affected and anonymous user aren't really suppose to login-in in the first place. However, anonymous user that happen to request a email which has already been used by a registered user will be denied. Please see comment in include/register.php starting with "# delete this record since the user is anonymous requesting the same email" for detailed explanation.

Modified for X-Cart Gold: Version 4.0.12 stock

Tested with: Version 4.0.12 stock
Apache 1.33, OpenSSL 0.9.6b, PHP 4.3.10, SQL 4.0.22

Intended Audience: This mod requires changes to various php, tpl files and some sql table(s) as well as outlined in "General Overview" below. If you are a store owner and have met the requirements for the modified and tested X-Cart versions, you can follow the instructions below and it should work. However, if you intend to make this mod work with previous X-Cart versions or make any changes to this mod, it is recommended that you hire a developer with development and coding knowledge to perform this task.

Disclaimer: This mod may work on other X-Cart versions, but it has not been tested. Therefore, use it at your own risk. We are not responsible for any loss in sales, time spent or damages that is direct or indirectly caused by this modification to your store. By using this modification, you have agreed all the terms to the license agreement and hold all personel indemfiable and harmless including but not limited to owners, shareholders, stakeholders, employees, contractors, or anyone else related to the business.

License: None/Freeware

As usual, always backup your current store or try it on a development store before integrating this with production.

General Overview:

files modified application logic related:
sql table modification
xcart_customers
files modified application logic related:
include/login.php
include/register.php
frontend gui related:
register.php include/check_useraccount.php
skin1/customer/main/register.tpl skin1/main/register_account.tpl
skin1/main/register_contact_info.tpl skin1/main/orders_list.tpl

each code section which has been modified has the comment header:
mod.use.email.rather.username

Instructions:

Prerequisites:
BACKUP, BACKUP, BACKUP!!
make sure no duplicate email exist in xcart_customers table also
make sure email field is active and required for admin and customers.
Also, remember that customers can only login using their emails once this mod is added.

Installation:

1. update sql table using ssh or sql patch from admin menu
If using ssh, issue command:
"mysql -u username -p dbname < update_tables.sql"
If using sql patch just use the command
"ALTER TABLE xcart_customers ADD UNIQUE (email);"

2. modify code
a. match the code section under the "find original code snippet" and "end original code snippet" with your source
b. replace original code section with the code section under the "replace modified code snippet"

3. repeat step 2 for each php and template files until all are done

-------------------------------------------------------------------------------------
file: update_tables.sql v1
Code:
# this script will make the following field(s) unique to avoid duplication # table(s) affected # xcart_customers # field(s) affected # email ALTER TABLE xcart_customers ADD UNIQUE (email);
-------------------------------------------------------------------------------------
file: register.php v1
Code:
# find original code snippet if ($REQUEST_METHOD == "POST" && $action == "cart") { if (empty($reg_error)) func_header_location("cart.php?mode=checkout&paymentid=$paymentid"); } $smarty->assign("login",$login); # end original code snippet # replace modified code snippet if ($REQUEST_METHOD == "POST" && $action == "cart") { if (empty($reg_error)) func_header_location("cart.php?mode=checkout&paymentid=$paymentid"); } # mod.use.email.rather.username $smarty->assign("login", func_query_first_cell("select email from $sql_tbl[customers] where login='$login'")); # end modified code snippet
-------------------------------------------------------------------------------------
file: include/check_useraccount.php v1
Code:
# find original code snippet $smarty->assign("login",$login); $smarty->assign("usertype",$current_area); # end original code snippet # replace modified code snippet # mod.use.email.rather.username $smarty->assign("login", func_query_first_cell("select email from $sql_tbl[customers] where login='$login'")); $smarty->assign("usertype",$current_area); # end modified code snippet
-------------------------------------------------------------------------------------
file: include/login.php v1
Code:
# mod1 # find original code snippet switch ($redirect) { case "admin": $redirect_to = DIR_ADMIN; break; case "provider": $redirect_to = DIR_PROVIDER; break; case "partner": $redirect_to = DIR_PARTNER; break; case "customer": default: $redirect_to = DIR_CUSTOMER; } # end original code snippet # replace modified code snippet switch ($redirect) { case "admin": $redirect_to = DIR_ADMIN; # mod.use.email.rather.username $c_area = 'A'; break; case "provider": $redirect_to = DIR_PROVIDER; break; case "partner": $redirect_to = DIR_PARTNER; break; case "customer": default: $redirect_to = DIR_CUSTOMER; } # end modified code snippet # mod2 # find original code snippet if ($REQUEST_METHOD == "POST") { $intershipper_recalc = "Y"; if ($mode == "login") { $username = $HTTP_POST_VARS["username"]; $password = $HTTP_POST_VARS["password"]; $user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE email='$username' AND usertype='$usertype' AND status='Y'"); # end original code snippet # replace modified code snippet if ($REQUEST_METHOD == "POST") { $intershipper_recalc = "Y"; if ($mode == "login") { $username = $HTTP_POST_VARS["username"]; $password = $HTTP_POST_VARS["password"]; # mod.use.email.rather.username # exception if current area is admin, use username or email instead if( $c_area == 'A' ) { $c_area = ''; $user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE (login='$username' OR email='$username') AND usertype='$usertype' AND status='Y'"); } else $user_data = func_query_first("SELECT * FROM $sql_tbl[customers] WHERE email='$username' AND usertype='$usertype' AND status='Y'"); # end modified code snippet
-------------------------------------------------------------------------------------
file: include/register.php v1
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 foreach($default_fields as $k => $v) { if($v['required'] == 'Y' && empty($$k) && $v['avail'] == 'Y') { if(($k == "b_county" || $k == 's_county')) { if($config["General"]["use_counties"] == "Y") { $fillerror = true; break; } } elseif($k != 'b_state' && $k != 's_state') { $fillerror = true; break; } elseif($k == 's_state' && func_query_first_cell("SELECT display_states FROM $sql_tbl[countries] WHERE code = '$s_country'") == 'Y') { $fillerror = true; break; } elseif($k == 'b_state' && func_query_first_cell("SELECT display_states FROM $sql_tbl[countries] WHERE code = '$b_country'") == 'Y') { $fillerror = true; break; } } } # end original code snippet # replace modified code snippet foreach($default_fields as $k => $v) { if($v['required'] == 'Y' && empty($$k) && $v['avail'] == 'Y') { if(($k == "b_county" || $k == 's_county')) { if($config["General"]["use_counties"] == "Y") { $fillerror = true; break; } } elseif($k != 'b_state' && $k != 's_state') { $fillerror = true; break; } elseif($k == 's_state' && func_query_first_cell("SELECT display_states FROM $sql_tbl[countries] WHERE code = '$s_country'") == 'Y') { $fillerror = true; break; } elseif($k == 'b_state' && func_query_first_cell("SELECT display_states FROM $sql_tbl[countries] WHERE code = '$b_country'") == 'Y') { $fillerror = true; break; } } } # mod.use.email.rather.username # check if email already exist in customers table 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; } } # 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
-------------------------------------------------------------------------------------
file: skin1/customer/main/register.tpl v1
Code:
{* find original code snippet *} {include file="main/register_account.tpl" userinfo=$userinfo} {* end original code snippet *} {* replace modified code snippet *} {* mod.use.email.rather.username, include register_account.tpl if not using anonymous checkout *} {if not ($anonymous ne "" and $config.General.disable_anonymous_checkout ne "Y")} {include file="main/register_account.tpl" userinfo=$userinfo} {/if} {* end modified code snippet *}
-------------------------------------------------------------------------------------
file: skin1/main/orders_list.tpl v1
Code:
{* find original code snippet *} <TD>{$orders[oid].firstname} {$orders[oid].lastname} ({$orders[oid].login})</TD> {* end original code snippet *} {* replace modified code snippet *} {* mod.use.emai.rather.username *} <TD>{$orders[oid].firstname} {$orders[oid].lastname} ({$orders[oid].email})</TD> {* end modified code snippet *}
-------------------------------------------------------------------------------------
file: skin1/main/register_account.tpl v1
Code:
{* mod1 *} {* find original code snippet *} {* Anonymous account *} <TR> <TD colspan="3">{$lng.txt_anonymous_account_msg}</TD> </TR> <TR> <TD align="right">{$lng.lbl_username}</TD> <TD></TD> <TD nowrap> <INPUT type="text" name="uname" size="32" maxlength="32" value="{$userinfo.login}"> </TD> </TR> {* end original code snippet *} {* replace modified code snippet *} {* Anonymous account *} <TR> <TD colspan="3">{$lng.txt_anonymous_account_msg}</TD> </TR> {* mod.use.email.rather.username, show email for username instead *} {if $default_fields.email.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_email}</TD> <TD>{if $default_fields.email.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="email" name="email" size="32" maxlength="128" value="{$userinfo.email}"> {if $emailerror ne "" or ($reg_error ne "" and $userinfo.email eq "" and $default_fields.email.required eq 'Y')}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {* mod.use.email.rather.username, disable this since no need to show username *} {if 0} <TR> <TD align="right">{$lng.lbl_username}</TD> <TD></TD> <TD nowrap> <INPUT type="text" name="uname" size="32" maxlength="32" value="{$userinfo.login}"> </TD> </TR> {/if} {* end modified code snippet *} {* mod2 *} {* find original code snippet *} {* NOT anonymous account *} <TR> <TD align="right">{$lng.lbl_username}</TD> <TD class="Star">*</TD> <TD nowrap> {if $userinfo.login ne "" || ($login eq $userinfo.uname && $login ne '')} {$userinfo.login|default:$userinfo.uname} <INPUT type="hidden" name="uname" value="{$userinfo.login|default:$userinfo.uname}"> {else} <INPUT type="text" id="uname" name="uname" size="32" maxlength="32" value="{if $userinfo.uname}{$userinfo.uname}{else}{$userinfo.login}{/if}"> {if ($reg_error ne "" and $userinfo.uname eq "" and $userinfo.login eq "") or $reg_error eq "U"}<FONT class="Star">&lt;&lt;</FONT>{/if} {/if} </TD> </TR> <TR> <TD align="right">{$lng.lbl_password}</TD> <TD><FONT class="Star">*</FONT></TD> <TD nowrap><INPUT type="password" id="passwd1" name="passwd1" size="32" maxlength="32" value="{$userinfo.passwd1}"> {if $reg_error ne "" and $userinfo.passwd1 eq ""}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {* end original code snippet *} {* replace modified code snippet *} {* NOT anonymous account *} {* mod.use.email.rather.username, show email for username instead *} {if $default_fields.email.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_email}</TD> <TD>{if $default_fields.email.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="email" name="email" size="32" maxlength="128" value="{$userinfo.email}"> {if $emailerror ne "" or ($reg_error ne "" and $userinfo.email eq "" and $default_fields.email.required eq 'Y')}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {* mod.use.email.rather.username, disable this since no need to show username *} {if 0} <TR> <TD align="right">{$lng.lbl_username}</TD> <TD class="Star">*</TD> <TD nowrap> {if $userinfo.login ne "" || ($login eq $userinfo.uname && $login ne '')} {$userinfo.login|default:$userinfo.uname} <INPUT type="hidden" name="uname" value="{$userinfo.login|default:$userinfo.uname}"> {else} <INPUT type="text" id="uname" name="uname" size="32" maxlength="32" value="{if $userinfo.uname}{$userinfo.uname}{else}{$userinfo.login}{/if}"> {if ($reg_error ne "" and $userinfo.uname eq "" and $userinfo.login eq "") or $reg_error eq "U"}<FONT class="Star">&lt;&lt;</FONT>{/if} {/if} </TD> </TR> {/if} {* mod.use.email.rather.username, output hidden username for include/register.php verification *} <INPUT type="hidden" name="uname" value="{$userinfo.login|default:$userinfo.uname}"> <TR> <TD align="right">{$lng.lbl_password}</TD> <TD><FONT class="Star">*</FONT></TD> <TD nowrap><INPUT type="password" id="passwd1" name="passwd1" size="32" maxlength="32" value="{$userinfo.passwd1}"> {if $reg_error ne "" and $userinfo.passwd1 eq ""}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {* end modified code snippet *}
-------------------------------------------------------------------------------------
file: skin1/main/register_contact_info.tpl v1
Code:
{* find original code snippet *} {if $default_fields.phone.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_phone}</TD> <TD>{if $default_fields.phone.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="phone" name="phone" size="32" maxlength="32" value="{$userinfo.phone}"> {if $reg_error ne "" and $userinfo.phone eq "" and $default_fields.phone.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {if $default_fields.email.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_email}</TD> <TD>{if $default_fields.email.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="email" name="email" size="32" maxlength="128" value="{$userinfo.email}"> {if $emailerror ne "" or ($reg_error ne "" and $userinfo.email eq "" and $default_fields.email.required eq 'Y')}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {if $default_fields.fax.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_fax}</TD> <TD>{if $default_fields.fax.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="fax" name="fax" size="32" maxlength="128" value="{$userinfo.fax}"> {if $reg_error ne "" and $userinfo.fax eq "" and $default_fields.fax.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {if $default_fields.url.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_web_site}</TD> <TD>{if $default_fields.url.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="url" name="url" size="32" maxlength="128" value="{$userinfo.url}"> {if $reg_error ne "" and $userinfo.url eq "" and $default_fields.url.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {include file="main/register_additional_info.tpl" section="C"} {/if} {* end original code snippet *} {* replace modified code snippet *} {* mod.use.email.rather.username, added a section suitable for anonymous accounts *} {if $anonymous ne "" and $config.General.disable_anonymous_checkout ne "Y"} {* Anonymous account *} {if $default_fields.phone.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_phone}</TD> <TD>{if $default_fields.phone.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="phone" name="phone" size="32" maxlength="32" value="{$userinfo.phone}"> {if $reg_error ne "" and $userinfo.phone eq "" and $default_fields.phone.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {if $default_fields.email.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_email}</TD> <TD>{if $default_fields.email.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="email" name="email" size="32" maxlength="128" value="{$userinfo.email}"> {if $emailerror ne "" or ($reg_error ne "" and $userinfo.email eq "" and $default_fields.email.required eq 'Y')}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {if $default_fields.fax.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_fax}</TD> <TD>{if $default_fields.fax.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="fax" name="fax" size="32" maxlength="128" value="{$userinfo.fax}"> {if $reg_error ne "" and $userinfo.fax eq "" and $default_fields.fax.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {if $default_fields.url.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_web_site}</TD> <TD>{if $default_fields.url.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="url" name="url" size="32" maxlength="128" value="{$userinfo.url}"> {if $reg_error ne "" and $userinfo.url eq "" and $default_fields.url.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {include file="main/register_additional_info.tpl" section="C"} {/if} {* /Anonymous account *} {else} {* NOT anonymous account *} {if $default_fields.phone.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_phone}</TD> <TD>{if $default_fields.phone.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="phone" name="phone" size="32" maxlength="32" value="{$userinfo.phone}"> {if $reg_error ne "" and $userinfo.phone eq "" and $default_fields.phone.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {* mod.use.email.rather.username, disable this and move to register_account.tpl *} {if 0} {if $default_fields.email.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_email}</TD> <TD>{if $default_fields.email.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="email" name="email" size="32" maxlength="128" value="{$userinfo.email}"> {if $emailerror ne "" or ($reg_error ne "" and $userinfo.email eq "" and $default_fields.email.required eq 'Y')}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {/if} {if $default_fields.fax.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_fax}</TD> <TD>{if $default_fields.fax.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="fax" name="fax" size="32" maxlength="128" value="{$userinfo.fax}"> {if $reg_error ne "" and $userinfo.fax eq "" and $default_fields.fax.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {if $default_fields.url.avail eq 'Y'} <TR> <TD align="right">{$lng.lbl_web_site}</TD> <TD>{if $default_fields.url.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> <TD nowrap> <INPUT type="text" id="url" name="url" size="32" maxlength="128" value="{$userinfo.url}"> {if $reg_error ne "" and $userinfo.url eq "" and $default_fields.url.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} </TD> </TR> {/if} {include file="main/register_additional_info.tpl" section="C"} {/if} {/if} {* end modified code snippet *}
__________________
X-Cart 4.xx Gold
Enterprise Linux
Reply With Quote
  #15  
Old 03-25-2005, 07:27 AM
 
mustang mustang is offline
 

eXpert
  
Join Date: Nov 2003
Location: US
Posts: 210
 

Default

I'd love to only allow users to use the email address in place of their username. It makes things much simpler for them.

My only problem is with the phone orders that are received. I'd like to allow either anonymous checkout or username checkout for these orders, since many of these people do not have email addresses. Maybe even use their telephone number as the username for these orders!

Any ideas on how this should be done??

Thanks.
__________________
X-Cart Gold 4.2.3
-----
PHP 5.2.17 | MySQL 5.1.52
Reply With Quote
  #16  
Old 03-25-2005, 05:38 PM
 
x-light x-light is offline
 

Member
  
Join Date: Mar 2005
Posts: 29
 

Default

Hi Mustang,

Quote:
My only problem is with the phone orders that are received. I'd like to allow either anonymous checkout or username checkout for these orders, since many of these people do not have email addresses. Maybe even use their telephone number as the username for these orders!

So what you are saying is that people without email addresses uses their phone as primary contact? If that is the case, you don't need this mod. I wouldn't recommend using their telephone number as the username as people's number do change. To X-Cart, the username is the primary and unique key so you don't want to change that very often if possible.

However, if you want to still use email without the username with customers , you can make a small adjustment to the login procedure to allow customers to login from email (for your email customers) or phone instead (for your phone customers). In registration, you may want to add a check to see if the customer enters a phone, then email is not necessary as a required field or vs. versa. I would still keep the username hidden and use the system to generate a unique id so not to confuse the customer. Let me know if this helps.

~x-light
__________________
X-Cart 4.xx Gold
Enterprise Linux
Reply With Quote
  #17  
Old 03-25-2005, 10:19 PM
 
x-light x-light is offline
 

Member
  
Join Date: Mar 2005
Posts: 29
 

Default minor update (forcing all emails to lowercase)

I forgot a minor detail where the code will allow duplicate email address thus cause an duplicate entry error in mysql since the email tests do not check for case sensitivity. The problem can be easily fixed by forcing all email address entries either at initial registration or profile updates to lowercase. Here is what you need to change.

file: include/register.php v1

find this section of code

Code:
# mod.use.email.rather.username # check if email already exist in customers table if( $email == func_query_first_cell("select email from $sql_tbl[customers] where email='$email'")) { # duplicate email not allowed $eerror = true; }

and replace with

Code:
# mod.use.email.rather.username # 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; }

~x-light
__________________
X-Cart 4.xx Gold
Enterprise Linux
Reply With Quote
  #18  
Old 03-31-2005, 02:13 PM
 
sportruck sportruck is offline
 

Advanced Member
  
Join Date: Dec 2003
Posts: 70
 

Default

Awesome, I got this mod working. Thanks for posting. There are a few places you need to modify different files and messages to make it consistent. Such as the emails (so users don't see their random username), password recovery, and login sections.
Reply With Quote
  #19  
Old 04-01-2005, 01:52 AM
  2019's Avatar 
2019 2019 is offline
 

Advanced Member
  
Join Date: Dec 2004
Posts: 76
 

Default

rated 99/100
keep up the good work
thnx!
__________________
// x-cart 4.1.9

X-CART CSS SKIN
XC SEO
IP Addresses in Users Online for all users
Color coded order status
Reply With Quote
  #20  
Old 04-01-2005, 02:07 PM
 
x-light x-light is offline
 

Member
  
Join Date: Mar 2005
Posts: 29
 

Default

Quote:
Awesome, I got this mod working. Thanks for posting. There are a few places you need to modify different files and messages to make it consistent. Such as the emails (so users don't see their random username), password recovery, and login sections.

Your welcome. Humm, I thought I already did that for login. However, if you have already made changes to the emails and password recovery section, please post the changes. I am quite busy working on other mods and may not be able to get back to this one right away. Thanks for pointing this out, see this is what's so great about this forum. Very informative feedbacks.


Quote:
rated 99/100
keep up the good work
thnx!

Hi, thanks for the feedback. I appreciate it. I will be posting a few more useful mods in the near future. Currently I am working on a mod that validates fields for registration on the server side. I looked for this everywhere in the forum and couldn't find it. So, I will write my own. I will post this mod soon as it is very important to validate your customer information before you send it to the sql db.

~x-light
__________________
X-Cart 4.xx Gold
Enterprise Linux
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Changing and adding new features


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:19 PM.

   

 
X-Cart forums © 2001-2018