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

Shipping/Billing Names upon Register

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 05-20-2004, 02:49 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

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

Default Shipping/Billing Names upon Register

Modded with: X-Cart 3.5.7

Always make a backup before applying any mod! Here is a quick file list: include/register.php, include/func.php, skin1/main/register_billing_address.tpl, skin1/main/register_shipping_address.tpl

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 defination:

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 with:

Code:
$userinfo["b_title"] = $userinfo["s_title"] ? $userinfo["s_title"] : $userinfo["title"]; $userinfo["b_firstname"] = $userinfo["s_firstname"] ? $userinfo["s_firstname"] : $userinfo["firstname"]; $userinfo["b_lastname"] = $userinfo["s_lastname"] ? $userinfo["s_lastname"] : $userinfo["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}">

Replace with:
Code:
{if $action eq "cart"} <INPUT type=hidden name="action" value="cart"> <INPUT type=hidden name="paymentid" value="{$paymentid}"> {/if}

Find the {/if} after the </tr> of the lastname area, and remove or comment it out {*/if*} You may also want to comment out the title field of the billing form as well.

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:
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'");

To the above.

6) Also update the insert statement of new customers:

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."')");

Note the b_firstname,b_lastname and s_firstname,s_lastname fields and variables.

This Should Do the trick, Ive done some moderate testing on this mod on a local copy so let me know if you find any snags.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #2  
Old 05-22-2004, 05:27 AM
 
mikebo mikebo is offline
 

Advanced Member
  
Join Date: Feb 2004
Location: Ohio
Posts: 72
 

Default

Hi Boomer

Thanks again for all the help you provide to the users of this forum. You have helped me out numerous times.

I tried many different ways to get the checkout process to carry thru the information typed in during step one of the checkout. Using the anonymous process, which is the only process I use in my store, I was not able to get the first and last names for shipping and billing info to do exactly what I needed.

I applied your mod, which you so nicely posted above, to my store. For the first time the first and last name info for shipping and billing info started to carry thru from step 1 to step 3 of the checkout. With some further adjustment to the include\func.php file, I was able to get it to do exactly what I needed.

Here is the revision you posted to the func.php file:

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

Here is the revision I made:

empty($userinfo["s_title"])? $userinfo["s_title"] = $userinfo["b_title"] : $userinfo["s_title"] = $userinfo["s_title"];
empty($userinfo["s_firstname"])? $userinfo["s_firstname"] = $userinfo["b_firstname"] : $userinfo["s_firstname"] = $userinfo["s_firstname"];
empty($userinfo["s_lastname"]) ? $userinfo["s_lastname"] = $userinfo["b_lastname"] : $userinfo["s_lastname"] = $userinfo["b_lastname"];

Now in my 3.5.7 store,

If the user leaves the shipping info empty at step 1 of checkout, the shipping info (including first and last name) will be filled in automatically with the billing info and carried thru to step 3 of checkout.

If the user fills in the shipping info at step 1 of checkout, the shipping info (including first and last names) will be filled in with the shipping info they entered, and carried thru to step 3 of checkout.

I've not tested this with all the payment methods in my store yet, but I don't see any problems with the moderate testing I've done.

Thank you for helping me streamline the checkout process.

Mike
__________________
Mike
X-Cart Gold
Version 4.6.0 PHP 5.2.17
Reply With Quote
  #3  
Old 06-07-2004, 05:35 PM
 
mikebo mikebo is offline
 

Advanced Member
  
Join Date: Feb 2004
Location: Ohio
Posts: 72
 

Default

Another forum member pointed out a mistake in the code I listed above. The last line should be:

empty($userinfo["s_lastname"]) ? $userinfo["s_lastname"] = $userinfo["b_lastname"] : $userinfo["s_lastname"] = $userinfo["s_lastname"];

Sorry for any confusion.

Mike
__________________
Mike
X-Cart Gold
Version 4.6.0 PHP 5.2.17
Reply With Quote
  #4  
Old 06-24-2004, 09:50 AM
 
mikebo mikebo is offline
 

Advanced Member
  
Join Date: Feb 2004
Location: Ohio
Posts: 72
 

Default

Jut thought I'd make a post here to let people know this problem has been fixed with the 3.5.8 version of XCart.

Mike
__________________
Mike
X-Cart Gold
Version 4.6.0 PHP 5.2.17
Reply With Quote
  #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
  #6  
Old 01-15-2006, 07:39 AM
 
Jerrad Jerrad is offline
 

X-Adept
  
Join Date: Nov 2004
Location: The Netherlands
Posts: 484
 

Default

First of all thanks for this mod!

I've carefully followed the instructions of boomer, then implemented the revision of mikobo and got it partial working:
phpmyadmin shows me that the shipping first & lastname are written to the datebase, but strange enough the shipping namefields
in the registerform are still populated with the billing first- & lastname...

I hope somebody can help me with this.
Many thanks in advance!

Jerrad
__________________
X-Cart 4.0.12
Heavy modified with paid, free and forum mods.
PHP 5.2.5 | MYSQL 5.0.51a
Reply With Quote
  #7  
Old 01-17-2006, 01:58 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

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

Default Re: Shipping/Billing Names upon Register

Quote:
Originally Posted by B00MER
Modded with: X-Cart 3.5.7

Are you trying to apply this mod with a different version of X-Cart than the 3.5.x branch?
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #8  
Old 01-17-2006, 02:32 PM
 
Jerrad Jerrad is offline
 

X-Adept
  
Join Date: Nov 2004
Location: The Netherlands
Posts: 484
 

Default

Oeps, I've got 4.0.12...

Strange enough it seems to work oke during checkout - customer can give a different shipping first - and last name, which gets saved without any problems.
But when a customer registers for the first time or wants to update his/her profile with different shipping information, the first - and last name gets overwritten by the billing names.
Address, zipcode and city are saved correctly.

So with {if $action eq "cart"} all the shipping information can be saved without any problem. Any other $action will only save the address, but not the first - and last name...

Any ideas how to solve this?
Thanks in advance!
__________________
X-Cart 4.0.12
Heavy modified with paid, free and forum mods.
PHP 5.2.5 | MYSQL 5.0.51a
Reply With Quote
  #9  
Old 02-01-2006, 09:11 PM
 
flyingsaucer flyingsaucer is offline
 

Member
  
Join Date: Sep 2005
Posts: 14
 

Default This must be a bug

This is either a bug or poor design, the other day, a customer asked me to update his shipping address on database (he was an elderly gentelman, could not figure out himself), anyways when I went to the use profile page, bingo! there were no fields to update for the shipping name and lastname.

I was confused and went to the database to see if the customer table has s_firstname, s_lastname fields and bingo, they are not there!

Shipping firstname and lastname are only saved to the database when an order was placed. However if the user just registers but does not complete the checkout then the shipping firstname and lastname are replaced with billing name/lastname.

On the payment page, there is a modify profile link, and when you go there and update info, it does not not store that data unless you complete the order.

That does not sound right to me. In my customer's case he was so confused and he sent an email and updated shipping name/lastname that way, cause he wants it to be shipped to his granddaughter.

This weird setup should definitely be fixed in the next release.

koksal
__________________
x-cart 4.0.16 (linux)
location: USA
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


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:45 PM.

   

 
X-Cart forums © 2001-2020