View Single Post
  #5  
Old 06-15-2005, 12:00 PM
 
phil_ phil_ is offline
 

Advanced Member
  
Join Date: Feb 2003
Location: Northern Ireland
Posts: 56
 

Default

Hi Guys,

I've just applied this code and it works (running 3.5x branch). Instead of having the shipping name coppied with the billing though, I prefer to allow the user to leave it blank without it being forceably overwritten with the billing name details.

Note that the original post by Boomer did not seem to work for the shipping name as it seemed to be substituted with the billing name after a re-save of the registration info, however the post by mikebo seemed to fix that problem, but in my case I didn't want that behaviour, rather I wanted to allow the option to leave the first and last name blank for the shipping.

So for my implementation, here's what I did (using Boomers code as a model):

1) X-Cart Admin Patch/Upgrade Apply this SQL patch:

Code:
ALTER TABLE `xcart_customers` ADD `b_firstname` VARCHAR( 128 ) NOT NULL , ADD `b_lastname` VARCHAR( 128 ) NOT NULL , ADD `s_firstname` VARCHAR( 128 ) NOT NULL , ADD `s_lastname` VARCHAR( 128 ) NOT NULL ;

This will add 4 new fields to the customers table.

2) Edit include/func.php and find the following in the func_userinfo() function definition:

Code:
$userinfo["b_title"] = $userinfo["s_title"] = $userinfo["title"]; $userinfo["b_firstname"] = $userinfo["s_firstname"] = $userinfo["firstname"]; $userinfo["b_lastname"] = $userinfo["s_lastname"] = $userinfo["lastname"];

replace it with:

Code:
empty($userinfo["s_title"]) ? $userinfo["s_title"] = "" : $userinfo["s_title"] = $userinfo["s_title"]; empty($userinfo["s_firstname"]) ? $userinfo["s_firstname"] = "" : $userinfo["s_firstname"] = $userinfo["s_firstname"]; empty($userinfo["s_lastname"]) ? $userinfo["s_lastname"] = "" : $userinfo["s_lastname"] = $userinfo["s_lastname"];

3) Edit skin1/main/register_billing_address.tpl find:

Code:
{if $action eq "cart"} <INPUT type=hidden name="action" value="cart"> <INPUT type=hidden name="paymentid" value="{$paymentid}"> <tr valign=middle> <td align=right>{$lng.lbl_title}</td> <td><font class=Star>*</font></td> <td nowrap> <select name=b_title class=OrderSelectArea > {section name=title loop=$name_titles} <option {if $userinfo.b_title eq $name_titles[title]}selected{/if}>{$name_titles[title]}</option> {/section} </select> </td> </tr> <tr valign=middle> <td align=right>{$lng.lbl_first_name}</td> <td><font class=Star>*</font></td> <td nowrap> <input type=text class=OrderTextArea name=b_firstname size=32 maxlength=32 value="{$userinfo.b_firstname}"> {if $reg_error ne "" and $userinfo.b_firstname eq ""}<font class=Star>&lt;&lt;</font>{/if} </td> </tr> <tr valign=middle> <td align=right>{$lng.lbl_last_name}</td> <td><font class=Star>*</font></td> <td nowrap> <input type=text class=OrderTextArea name=b_lastname size=32 maxlength=32 value="{$userinfo.b_lastname}"> {if $reg_error ne "" and $userinfo.b_lastname eq ""}<font class=Star>&lt;&lt;</font>{/if} </td> </tr> {/if}

and replace with

Code:
{if $action eq "cart"} <INPUT type=hidden name="action" value="cart"> <INPUT type=hidden name="paymentid" value="{$paymentid}"> {/if} <tr valign=middle> <td align=right>{$lng.lbl_title}</td> <td><font class=Star>*</font></td> <td nowrap> <select name=b_title class=OrderSelectArea > {section name=title loop=$name_titles} <option {if $userinfo.b_title eq $name_titles[title]}selected{/if}>{$name_titles[title]}</option> {/section} </select> </td> </tr> <tr valign=middle> <td align=right>{$lng.lbl_first_name}</td> <td><font class=Star>*</font></td> <td nowrap> <input type=text class=OrderTextArea name=b_firstname size=32 maxlength=32 value="{$userinfo.b_firstname}"> {if $reg_error ne "" and $userinfo.b_firstname eq ""}<font class=Star>&lt;&lt;</font>{/if} </td> </tr> <tr valign=middle> <td align=right>{$lng.lbl_last_name}</td> <td><font class=Star>*</font></td> <td nowrap> <input type=text class=OrderTextArea name=b_lastname size=32 maxlength=32 value="{$userinfo.b_lastname}"> {if $reg_error ne "" and $userinfo.b_lastname eq ""}<font class=Star>&lt;&lt;</font>{/if} </td> </tr>

4) Edit skin1/main/register_shipping_address.tpl:

And remove or comment out the {if $action eq "cart"} around the title, firstname and lastname fields so they show on all register forms. You may also want to remove or comment out the shipping title field.

5) Edit include/register.php and modify the update query to:

Code:
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_firstname='$b_firstname', b_lastname='$b_lastname', b_address='$b_address', b_city='$b_city', b_state='$b_state', b_country='$b_country', b_zipcode='$b_zipcode', s_firstname='$s_firstname', s_lastname='$s_lastname', s_address='$s_address', s_city='$s_city', 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='".text_crypt($card_number)."', card_expire='$card_expire', card_cvv2='$card_cvv2', pending_membership='$pending_membership', ssn='$ssn', change_password='$change_password' WHERE login='$login' and usertype='$login_type'");

6) Also update the insert statement of new customers to:

Code:
db_query("insert into $sql_tbl[customers] (login,usertype,membership,password,password_hint,password_hint_answer,title,firstname,lastname,company,b_firstname,b_lastname,b_address,b_city,b_state,b_country,b_zipcode,s_firstname,s_lastname,s_address,s_city,s_state,s_country,s_zipcode,phone,email,fax,url,card_name,card_type,card_number,card_expire,card_cvv2,first_login,status,referer,pending_membership,ssn) values ('$uname','$usertype','".@$membership."','$crypted','".@$password_hint."','".@$password_hint_answer."','$title','$firstname','$lastname','$company','$b_firstname','$b_lastname','$b_address','$b_city','$b_state','$b_country','$b_zipcode','$s_firstname','$s_lastname','$s_address','$s_city','$s_state','$s_country','$s_zipcode','$phone','$email','$fax','$url','".@$card_name."','".@$card_type."','".text_crypt(@$card_number)."','".@$card_expire."','".@$card_cvv2."','".time()."','Y','".@$RefererCookie."','".@$pending_membership."','".@$ssn."')");
__________________
-----------------------------------------
X-Cart5 v5.2.16 (Live)
-----------------------------------------
Reply With Quote