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)

adubas 08-30-2004 05:34 PM

check box for "same as billing address"
 
When a customer goes to put in personal info, there needs to be a way for them to click for shipping address "same as billing address" - the defaul says leave blank if same as billing address. If you use UPS online tools, it does not work. The fields stay mandatory no matter if you make it not mandatory or not... is there a way around this so my customers do not have to type the info 2 times on the same page? Leaving it blank like the directions say does not work.

shan 08-31-2004 07:25 AM

moved to bugs

inksticks 09-01-2004 01:55 PM

various bugs
 
Here are some suggestions some I think are just bugs that got over looked.

Make the 'contact us' 'state' and 'country' fields work the same as the 'customer profile' 'state' and 'country' fields. i.e. When a customer selects a country the appropriate states are presented rather then showing all available states for all countries.

Be able to choose the checkout 'active' and 'required' fields as you can for the user profile options in the admin general settings. This probably was over looked or assumed that setting them for customer profile would set them for checkout but they seem to work independently.

Do not display the default shipping city, state and zip code when customer uses anonymous checkout. Keep the fields blank as they are for the billing fields. So that they will copy the billing information when not filled in. A better approach would be to have a check box that the customer could check when his shipping address was the same as the billing. By clicking this check box the customers billing fields would be automatically copied to the shipping fields.

I hope that we can get some of these bugs worked out of X-cart soon. It's a great product!

autocom 09-10-2004 04:36 PM

Error message
 
When I tried to leave the shipping address blank, it gives me an error message.
( Please make sure you properly filled in all the required fields! )is the message I get if I don't put in the shipping address. Then, we have to fill it out twice... I am using X-Cart 4.0

Can someone help?

EnriqueHavoc 09-10-2004 05:37 PM

i agree a checkbox would really help..

jimmy_ 10-11-2004 01:54 PM

Has anyone developed this checkbox?? I would be willing to pay for such a thing.... Could someone please help???

PhilJ 10-13-2004 11:31 AM

Possible solution...
 
Backup files first. Code works for me in v4.0.5

I've not tested it with a drop down menu for states/counties, but it should work ok.

I use an input box for the state/county field. When I change country, it resets the state field, but I can live with that.

---------------------------

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

Code:

{literal}
<script language="JavaScript1.2">

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

</script>
{/literal}


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

add

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 ======= *}


---------------------------

Done.

I would then change the language variable - lbl_shipping_address_registration

from

Code:

Shipping Address (leave empty if same as billing address)

to just

Code:

Shipping Address

inksticks 10-14-2004 06:30 AM

This mod didn't work for me. I carefully followed the instructions but I'm getting an error on the checkout page both when the page loads and when I click on the 'Use Billing Address as Shipping Address' checkbox. I would appreciate help figuring out what is wrong. You can test it for yourself at http://www.inksticks.com/store

PhilJ 10-14-2004 06:33 AM

As I mentioned, I haven't tested it with drop down menus for the states field. I'll get back to you with a fix shortly.

PhilJ 10-14-2004 07:02 AM

Why can I not edit my post?

PhilJ 10-14-2004 07:06 AM

Remove

Code:

{literal}
<script language="JavaScript1.2">


and

Code:

</script>
{/literal}


from step 1, and then refresh.

inksticks 10-14-2004 07:22 AM

Great! no more errors. However l thought when I click on the box that it would populate the shipping address fields. When I click it appears that nothing happens but I do not get any error messages either. Is this right? It would be better is seems if the address as visibly copied when the customer clicks the box.

inksticks 10-15-2004 07:26 AM

In Internet Explorer it does fill the shipping fields when the box is checked but in Mozilla Firebox it does not. It looks like it was a problem with my browser.

chilll33 11-04-2004 05:22 PM

copy billing address to shipping
 
This works great, how would I make this also copy the County?

cotc2001 12-17-2004 12:55 PM

Quote:

Originally Posted by inksticks
In Internet Explorer it does fill the shipping fields when the box is checked but in Mozilla Firebox it does not. It looks like it was a problem with my browser.


Didn't populate for me when I just tested it a second ago in IE 6, it gave out a javascript error.

joestern 01-05-2005 10:07 AM

I am getting an error also and it doesn't populate the fields.

Inksticks--did you do anything special to get yours working?

This is a great feature, but something is not working right; I'm using IE 6.0.

Bella Forma 01-06-2005 10:42 PM

This is just what I am looking for.... please someone get it working :D

stryker898 01-07-2005 09:20 AM

Yea, I just tried this and I'm getting Java error and its not populating fields. Is there any X-cart pro's that can get this working. I'm sure a BUNCH of folks would use this!!! THANKS FOR ANY HELP

PhilJ 01-07-2005 10:47 AM

If this thread can be moved to custom mods, I'll update my original post. You can't edit posts in this forum.

joestern 01-09-2005 08:25 PM

Until that time, can you copy/paste and/or repost? Or perhaps PM with the updates? I'd hugely appreciate it!

SMDStudios 01-10-2005 04:25 AM

This appears not necessary for the 4.0.x versions??? Or is this mod just for the thrill of having the info actually populate into the fields? :)

joestern 01-10-2005 04:30 AM

I don't use 4.0x, and I would prefer to have the info populate.

CC 01-16-2005 06:20 AM

As an update to this, find the following, this works in 4.0.9 and should work in 4.0.10

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


This will carry over names, address lines, states/counties depending on what you have and zip/post code. We only ship in one country so I havent tested the country drop down, but it should work ok.
Only on the checkout signup will this work for names.

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.

The other files are just the same, although I presonally prefer a Button to click instead of a tick box. Looks more professional.

CC 01-16-2005 06:25 AM

I should add, the First name and Last name needs to be removed from the Billling Address info in XC IMO.

I havent got around to removing them yet, but it is stupid that a new customer has to give 3 names on checkout! Thats 6 boxes they have to fill in just to give names.

This IMO is silly as a lot of customers leave sites based on complicated signup forms, this not only looks complicated, it is totally unnecessary.

Not to mention this is open to a security risk or easy mistakes for new customers on signup.

Anyway, cant say too much as that is way off topic. ;)

joestern 01-17-2005 08:00 AM

Thanks for posting the revised code.

Unfortunately, this still does not seem to be working for me.... I am using version 3.x of x-cart, not 4.x Does anyone have any idea whether that might be the cause, and where I would look to see about changing the .js file to fix this for the older version?

The problem I'm having is that I get an error in IE, and when I check the box, it does not populate the new fields. The error I get is:

Code:

Line: 9
Char: 1
Error: Object required
Code: 0



Thanks in advance--I really want to get this working. It's a GREAT mod!

CC 01-17-2005 09:58 AM

Looks like your fields are named differently to the 4.0.x fields.

If you look in the copybilling.js code it is pretty straight forward.
Look to see what your fields are call in 3.x and then match them up the this code.

joestern 01-17-2005 10:20 AM

I looked in 3.x and the fields appear to be the same.

CC 01-17-2005 10:31 AM

#-o

I'll take a look shortly...

joestern 01-17-2005 11:17 AM

I hugely appreciate it. I should say that address_2 in our cart is address2, which I changed in copybilling.js. It fixed an earlier error, but produced the "object required" error in the earlier post.

joestern 01-17-2005 08:29 PM

Update: I've figured out where the problem is, but can't seem to get it fixed.

There are two problems; one I have figured out. The firstname/lastname needed to be "b_firstname" and "b_lastname"...easy.

It also appears that it is the "state" code that is causing a problem. If I remove all of the state code from copybilling.js, it works fine, but of course does not copy the state over. I'm wondering whether 3.x handles the state selection differently than 4.x. Here is my states.tpl file:

Code:

{* $Id: states.tpl,v 1.1.4.3 2004/04/09 07:07:28 svowl Exp $ *}
{if $states ne ""}
<select name="{$name}" {$style}>
{* <option value="XX">Please Select Below</option> *}
{section name=state_idx loop=$states}
<option value="{$states[state_idx].state_code}"{if $default eq $states[state_idx].state_code and $default_country eq $states[state_idx].country_code} selected{/if}>{$states[state_idx].state}</option>
{/section}
</select>
{else}
<input type=text size=32 name="{$name}" value="{$default}">
{/if}


Here's the relevant part of register_billing_address.tpl:

Code:

<tr valign=middle>
<td align=right>{$lng.lbl_state}</td>
<td>{if $states ne ""}<font class=Star>*</font>{/if}</td>
<td nowrap>
{include file="main/states.tpl" states=$states name="b_state" default=$userinfo.b_state default_country=$userinfo.b_country}
</td>
</tr>


Any thoughts would be greatly appreciated.

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 11:13 AM.

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