There are a lot of threads regarding entering names 3 times in the checkout register form. The main one has over 3500 views and 6 pages of discussion. If like me you find this confusing and you need a fix for standard 4.0.13 that covers most requirements, then hopefully this will help. (If you are an administrator and I have started a new topic when I shouldn't, sorry, just trying to make a complicated problem to solve via the forum simpler.)
The main thread (
http://forum.x-cart.com/viewtopic.php?t=17146&highlight=profile) branches off to solve the problem for version 3, then for Jon's EzCheckout, making it hard to follow and implement a standard fix.
This post:
- Saves your customer typing in names more than once in the checkout register form.
still allows them to enter different names if they want to for Billing and Shipping
Designed for standard 4.0.13
Makes changes to the register form in checkout.
Accounts for fact there are 2 register forms, therefore preserves normal register/create profile form
When customer starts the form, enters First and last name; these are duplicated to Billing Address (but not to Shipping)
Fills in the rest of Billing Address. Click the check box to duplicate name and address to Shipping.
Includes County/State and Country.
Doesn't matter if fields are mandatory, as they will get filled in one way or the other, but doesn't remove them as they may well be needed.
1) Open main/register_personal_info.tpl
Find INPUT fields for firstname and lastname
ADD THIS CODE to end of tag
onChange="populateProfile()"
e.g.
<INPUT type="text" id="firstname" name="firstname" size="32" maxlength="32" value="{$userinfo.firstname}" onChange="populateProfile()">
2) Open main/register_billing_address.tpl
After the last </TR>
add this code
{* ======== COPY BILLING TO SHIPPING MOD ======= *}
{if $action eq "cart"}
<TR>
<TD align="right"></TD>
<TD></TD>
<TD nowrap>
<input type="checkbox" name="copyb" onclick=javascript
:copybilling(this.form);>Use {$lng.lbl_billing_address} as {$lng.lbl_shipping_address}
</TD>
</TR>
{/if}
{* ======== COPY BILLING TO SHIPPING MOD ======= *}
3) in skin1, make copybilling.js
function InitSaveVariables_shipping(form){
s_firstname = form.s_firstname.value;
s_lastname = form.s_lastname.value;
s_address = form.s_address.value;
s_address_2 = form.s_address_2.value;
s_city = form.s_city.value;
s_state = form.s_state.value;
_s_state = document.getElementById('_s_state').value;
s_country = form.s_country.value;
s_zipcode = form.s_zipcode.value;
}
function copybilling(form){
if (form.copyb.checked){
InitSaveVariables_shipping(form);
form.s_firstname.value = form.firstname.value;
form.s_lastname.value = form.lastname.value;
form.s_address.value = form.b_address.value;
form.s_address_2.value = form.b_address_2.value;
form.s_city.value = form.b_city.value;
form.s_country.value = form.b_country.value;
form.s_zipcode.value = form.b_zipcode.value;
change_states(document.getElementById('s_country') , 's_state', 'State/Province', '', '', '', '');
form.s_state.value = form.b_state.value;
document.getElementById('_s_state').value = document.getElementById('_b_state').value;
}
else {
form.s_firstname.value = "";
form.s_lastname.value = "";
form.s_address.value = "";
form.s_address_2.value = "";
form.s_city.value = "";
form.s_country.value = form.b_country.value;
form.s_zipcode.value = "";
change_states(document.getElementById('s_country') , 's_state', 'State/Province', '', '', '', '');
form.s_state.value = form.b_state.value;
document.getElementById('_s_state').value = "";
}
}
4) Open common_js.tpl
Add this function
function populateProfile() {
document.registerform.s_firstname.value = document.registerform.firstname.value;
document.registerform.s_lastname.value = document.registerform.lastname.value;
document.registerform.b_firstname.value = document.registerform.firstname.value;
document.registerform.b_lastname.value = document.registerform.lastname.value
}
5)in skin1/customer/home.tpl
after
Code:
<link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}">
add this code
Code:
<script language=JavaScript1.3 src="{$SkinDir}/copybilling.js"></script>
Have basically taken work done by these people and put it all together in something that works for me; hopefully someone else can make use of it...
Credits:
Bob: bobcc99
http://forum.x-cart.com/viewtopic.php?t=17146&highlight=profile
PhilJ
CC
Bradc