X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   check box for "same as billing address" (https://forum.x-cart.com/showthread.php?t=9160)

joestern 01-17-2005 08:40 PM

Ok--I got it. Here is the copybilling.js for 3.x...or at least this is what worked for me:

Code:

function InitSaveVariables_shipping(form){
s_firstname = form.s_firstname.value;
s_lastname = form.s_lastname.value;
s_company = form.s_company.value; 
s_address = form.s_address.value;
s_address2 = form.s_address2.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.b_firstname.value;
form.s_lastname.value = form.b_lastname.value;
form.s_company.value = form.b_company.value;
form.s_address.value = form.b_address.value;
form.s_address2.value = form.b_address2.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_company.value = "";
  form.s_address.value = "";
  form.s_address2.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 = "";
 <!--  document.getElementById('_s_state').value = "";
  }
}


CopperB 02-07-2005 05:08 PM

Fist off thanks for this MOD. It is great. As stated it should be standard in Xcart.

The mod works just as it should be but I have added an " Additional " Phone field in Billing and Shipping. As this is an additional field the code is not copying the phone field. I have not been able to figure out the additional code I need to add in the copybilling.js Also if I need to change any of the code in the other templates used.

If anyone knows what I need to add/change that would be great.

Thanks

eaglemobiles 02-07-2005 07:26 PM

Hi,

Thanks for your great work, i am using 4.0.11
I followed all of your instructions change the last code you posted but i still getting error.

I will be grateful for help

Thanks

CopperB 02-07-2005 08:33 PM

1) Create a new file in the skin1 directory called copybilling.js
add this code:

Code:

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 = "";
  }
}


2) 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>

3) find skin1/main/register_billing_address.tpl

After the last </TR>
add this code
Code:

{* ======== COPY BILLING TO SHIPPING MOD ======= *}
<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>
{* ======== COPY BILLING TO SHIPPING MOD ======= *}



I have tested in Firefox 1.o and IE 6.0 and both work

Hope this helps

jeremy35 02-08-2005 01:46 PM

CopperB

Thanks, this worked great for me!

CopperB 02-08-2005 02:08 PM

NP jeremy. Glad to hear that it worked for you.

Has anyone tried this with an " Additional " Phone field in Billing and Shipping.

As this is an additional field the code mod is not copying the phone field. I have not been able to figure out the additional code I need to add in the copybilling.js

Also if I need to change/add any of the code in the other templates used.


Thanks

CC 02-08-2005 02:20 PM

jeremy35 you still got errors man.

Just checked it out on your site...

CC 02-08-2005 02:24 PM

It would appear that some are not giving consideration to the two different registration forms.

Remeber, there is a Checkout sign up page AND and general register page.

They dont have the same sign up fields.
The general sign up page does not ask for the a Name twice, the checkout sign up does.

So on the general signup you have no name field to carry across twice, hence the error.

Either create two templates for this or use this .js code:
Code:

function InitSaveVariables_shipping(form){
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 = form._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_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_state.value = form.b_state.value;
form._s_state.value = form._b_state.value;
form.s_country.value = form.b_country.value;
form.s_zipcode.value = form.b_zipcode.value;
}

else {
  form.s_address.value = "";
  form.s_address_2.value = "";
  form.s_city.value = "";
  form.s_state.value = form.b_state.value;
  form._s_state.value = "";
  form.s_country.value = form.b_country.value;
  form.s_zipcode.value = "";
  }
}


CopperB 02-08-2005 03:30 PM

CC

You are right. It works on my checkout sign up but not on the general signup.


This is from a post of yours earlier in this thread.

Quote:

On register.php this will not work, as it doesnt ask for a name.
To make it work you need PhilJ's code you need to create a second register_billing_address.tpl such as register_billing_address2.tpl which would look to copybilling2.js with PhilJ's code in.
Using the code above will leave you with JS errors on the page.



Would you be able to post the code for those 2 new files and what other templates need modified.

Thanks

DogByteMan 02-08-2005 04:00 PM

Instructions for 4.0.x using the ezCheckout mod by jon:

In your skin1 folder create the following files

copybilling1.js
Code:

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 = "";
  }
}


copybilling2.js
Code:

function InitSaveVariables_shipping(form){
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 = form._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_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_state.value = form.b_state.value;
form._s_state.value = form._b_state.value;
form.s_country.value = form.b_country.value;
form.s_zipcode.value = form.b_zipcode.value;
}

else {
  form.s_address.value = "";
  form.s_address_2.value = "";
  form.s_city.value = "";
  form.s_state.value = form.b_state.value;
  form._s_state.value = "";
  form.s_country.value = form.b_country.value;
  form.s_zipcode.value = "";
  }
}


In skin1/customer/home_checkout.tpl

after
Code:

<link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}">

add this code
Code:

<script language=JavaScript1.3 src="{$SkinDir}/copybilling1.js"></script>

In skin1/customer/home.tpl

after
Code:

<link rel="stylesheet" href="{$SkinDir}/{#CSSFile#}">

add this code
Code:

<script language=JavaScript1.3 src="{$SkinDir}/copybilling2.js"></script>

Find skin1/main/register_billing_address.tpl

After the last </TR>
add this code
Code:

{* ======== COPY BILLING TO SHIPPING MOD ======= *}
<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>
{* ======== COPY BILLING TO SHIPPING MOD ======= *}



All times are GMT -8. The time now is 08:44 PM.

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