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)

bestdata 04-20-2005 01:20 PM

check box for "same as billing address
 
Siripakdi ;

please email me at xcartdev@diamondmm.com . I will send you the file. If it works for you than we can publish it.

:)

torola 05-04-2005 04:47 AM

Quote:

Originally Posted by torola
Quote:

Originally Posted by CC
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 = "";
  }
}




The code works great except for one thing.

Here is my situation

My default country is Canada, so once I enter the registration page automatically country Canada is selected and you can choose Canadian Provinces.

Now, when a customer from US comes on the page and enters his address, changes country to United Stetes, and then chooses one of the US states, and everything seems OK

Then when you click on

"Use billing same as shipping addres" everything gets moved to the Shipping section, except for the states still show only Canadian Provinces even though the country changed to United States, you can only select Canadian province here.

Please let me know if this can be resolved somehow.

Thanks for the great mod.
Tom


Did anyone get a chance to fix this problem with state/province copying?
Thanks
Tom

r.jones 05-18-2005 11:41 AM

Simplifying the Checkout Form
 
This is another workaround for X-Cart Gold version 4.0.13 that I am trying on a new installation (not live yet). It needs some more testing, but may help others with this problem. Perhaps this post belongs in 4.0.13 - Cannot do anonymous checkout or register. Both threads are aimed at solving the problem of entering names more than once.

Step 1:

General Settings : User Profile options

Set "First Name" and "Last Name" to Active and Required.

Step 2:

Apply this patch, http://forum.x-cart.com/download.php?id=9 which allows the ship to names to be left blank. Shoppers will see a message: Shipping Address (leave empty if same as billing address). The patch changes only a few lines in two files. The "-" (minus sign) indicates the code that is removed, and the "+" (plus sign) indicates the code that replaces it.

Step 3:

Hide the billing names by changing in register_billing_address.tpl starting at about line 28 from:

Code:

{if $default_fields.firstname.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_first_name}</TD>
<TD>{if $default_fields.firstname.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" name="b_firstname" size="32" maxlength="32" value="{$userinfo.b_firstname}">
{if $reg_error ne "" and $userinfo.b_firstname eq "" && $default_fields.firstname.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{if $default_fields.lastname.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_last_name}</TD>
<TD>{if $default_fields.lastname.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" name="b_lastname" size="32" maxlength="32" value="{$userinfo.b_lastname}">
{if $reg_error ne "" and $userinfo.b_lastname eq "" && $default_fields.lastname.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}


to:

Code:

{if $default_fields.firstname.avail eq 'Y'}
{* <TR> *}
{* <TD align="right">{$lng.lbl_first_name}</TD> *}
{* <TD>{if $default_fields.firstname.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> *}
{* <TD nowrap> *}
<INPUT type="hidden" name="b_firstname" size="32" maxlength="32" value="{$userinfo.firstname}">
{* {if $reg_error ne "" and $userinfo.b_firstname eq "" && $default_fields.firstname.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} *}
{* </TD> *}
{* </TR> *}
{/if}

{if $default_fields.lastname.avail eq 'Y'}
{* <TR> *}
{* <TD align="right">{$lng.lbl_last_name}</TD> *}
{* <TD>{if $default_fields.lastname.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD> *}
{* <TD nowrap> *}
<INPUT type="hidden" name="b_lastname" size="32" maxlength="32" value="{$userinfo.lastname}">
{* {if $reg_error ne "" and $userinfo.b_lastname eq "" && $default_fields.lastname.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if} *}
{* </TD> *}
{* </TR> *}
{/if}


Step 4:

Make an onBlur event to move data entered in the personal name fields to the billing fields by changing in register_personal_info.tpl starting at about line 27 from:

Code:

<INPUT type="text" id="firstname" name="firstname" size="32" maxlength="32" value="{$userinfo.firstname}">
{if $reg_error ne "" and $userinfo.firstname eq "" && $default_fields.firstname.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{if $default_fields.lastname.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_last_name}</TD>
<TD>{if $default_fields.lastname.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="lastname" name="lastname" size="32" maxlength="32" value="{$userinfo.lastname}">


to:

Code:

<SCRIPT type="text/javascript">
{literal}
function update_b_firstname() {
document.registerform.b_firstname.value = document.registerform.firstname.value;
}
{/literal}
</SCRIPT>

<SCRIPT type="text/javascript">
{literal}
function update_b_lastname() {
document.registerform.b_lastname.value = document.registerform.lastname.value;
}
{/literal}
</SCRIPT>

<INPUT type="text" id="firstname" name="firstname" size="32" maxlength="32" value="{$userinfo.firstname}" onBlur="update_b_firstname()">
{if $reg_error ne "" and $userinfo.firstname eq "" && $default_fields.firstname.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{if $default_fields.lastname.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_last_name}</TD>
<TD>{if $default_fields.lastname.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="lastname" name="lastname" size="32" maxlength="32" value="{$userinfo.lastname}" onBlur="update_b_lastname()">


cphillips 06-07-2005 01:53 PM

Can someone post a step by step guide
 
I followed the instructions and its not working for me.

I get errors on my page and nothing copies over.

I do have 2 additional fields called phone in shipping and billing ( could this be a problem?)

Can someone post a current step by step instruction for this change?

Thanks!

polkadot 06-14-2005 08:33 AM

I would very much appreciate a current step by step for 4.0.13 as well!

steveparks 06-15-2005 09:44 AM

works in 4.0.13
 
Hi all

I got this working ok in 4.0.13

Have you applied the patch mentioned at the beginning of the post? http://forum.x-cart.com/download.php?id=9

The only thing I did differently was the position of the {literal} tags. I put them outside the <SCRIPT> tags. I don't know whether that would make a difference though, it's just the way I've always done it.

Code:

{literal}
<SCRIPT type="text/javascript">
function update_b_firstname() {
document.registerform.b_firstname.value = document.registerform.firstname.value;
}
function update_b_lastname() {
document.registerform.b_lastname.value = document.registerform.lastname.value;
}
</SCRIPT>
{/literal}


is the way i did the javascript functions. not much difference though.

steve

GriffithLea 06-15-2005 07:47 PM

This is my first post, so I hope that I get it right.

I'm new to Xcart, having set up my first store (4.0.13) over the past 3-4 weeks.

I mostly like Xcart, but I was disappointed as we all are in this thread with the clunky anonymous checkout (WRT title, firstname, & lastname having to be entered three times).

I like it that the user has the flexibility to be one person, bill to a 2nd person, and ship to a 3rd, but really this is not a usual situation in my mind. So I've read with great interest this thread and have taken the great suggestions and code fragments and put together my own version of the anonymous checkout form.

My mod has two checkboxes, one to copy title/firstname/lastname in Personal Information down to billing address, and another to copy the billing address (including b_title/b_firstname/b_lastname) down to shipping address. I borrowed heavily from all the posts here. What I've added is the title stuff and also when you uncheck, it goes back to what it was before you checked (which seemed to be intended in all the copybilling.js files that I saw, but not fully fleshed out).

I don't think this breaks the user registration form.

The .js files go in skin1.

copynames.js:

Code:

function InitSaveVariables_names(form) {
  b_title    = form.b_title.value;
  b_firstname = form.b_firstname.value;
  b_lastname  = form.b_lastname.value;
}

function copynames(form){
  if (form.copyn.checked){
    InitSaveVariables_names(form);
    form.b_title.value    = form.title.value;
    form.b_firstname.value = form.firstname.value;
    form.b_lastname.value  = form.lastname.value;
  } else {
    form.b_title.value    = b_title;
    form.b_firstname.value = b_firstname;
    form.b_lastname.value  = b_lastname;
  }
}


copybilling.js:

Code:

function InitSaveVariables_shipping(form) {
  s_title = form.s_title.value;
  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_title.value = form.title.value;
    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;
    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;
    form.s_country.value = form.b_country.value;
    form.s_zipcode.value = form.b_zipcode.value;
  } else {
    form.s_title.value = s_title;
    form.s_firstname.value = s_firstname;
    form.s_lastname.value = s_lastname;
    form.s_address.value = s_address;
    form.s_address_2.value = s_address_2;
    form.s_city.value = s_city;
    change_states(document.getElementById('s_country'), 's_state', 'State/Province', '', '', '', '');
    form.s_state.value = s_state;
    document.getElementById('_s_state').value = _s_state;
    form.s_country.value = s_country;
    form.s_zipcode.value = s_zipcode;
  }
}


home.tpl diff:

Code:

--- skin1_original/customer/home.tpl    2004-12-01 09:15:48.000000000 -0600
+++ skin1/customer/home.tpl    2005-06-15 18:51:31.000000000 -0500
@@ -20,6 +20,8 @@
 </TITLE>
 { include file="meta.tpl" }
 <LINK rel="stylesheet" href="{$SkinDir}/{#CSSFile#}">
+<script language=JavaScript1.3 src="{$SkinDir}/copybilling.js"></script>
+<script language=JavaScript1.3 src="{$SkinDir}/copynames.js"></script>
 </HEAD>
 <BODY leftmargin="0" topmargin="0" rightmargin="0" bottomargin="0" marginwidth="0" marginheight="0">
 { include file="rectangle_top.tpl" }


register_billing_address.tpl diff:

Code:

--- skin1_original/main/register_billing_address.tpl    2005-03-09 05:44:27.000000000 -0600
+++ skin1/main/register_billing_address.tpl    2005-06-15 18:57:57.000000000 -0500
@@ -8,6 +8,17 @@
 {/if}
 
 {if $action eq "cart"}
+
+{* ======== COPY NAMES TO BILLING MOD ======= *}
+<TR>
+<TD align="right"></TD>
+<TD></TD>
+<TD nowrap>
+<input type="checkbox" name="copyn" onclick="javascript:copynames(this.form);">Use {$lng.lbl_personal_information} in {$lng.lbl_billing_address}


+</TD>
+</TR>
+{* ======== COPY NAMES TO BILLING MOD ======= *}
+
 <INPUT type="hidden" name="action" value="cart">
 <INPUT type="hidden" name="paymentid" value="{$paymentid}">


register_shipping_address.tpl diff:

Code:

--- skin1_original/main/register_shipping_address.tpl  2005-03-09 05:44:27.000000000 -0600
+++ skin1/main/register_shipping_address.tpl    2005-06-15 18:25:50.000000000 -0500
@@ -7,6 +7,17 @@
 {/if}
 
 {if $action eq "cart"}
+
+{* ======== 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 ======= *}
+
 {if $default_fields.title.avail eq 'Y'}
 <TR>
 <TD align="right">{$lng.lbl_title}</TD>


I think that that's everything. I'd be interested to know if anyone can see anything wrong with it.

Griff

GriffithLea 06-16-2005 07:58 AM

I forgot to ask something in my previous post. Can someone explain the change_states function to me? There seems to be three lines of code necessary to copy the billing state down to the shipping state, and I don't quite understand what's going on there. I did notice that the drop-down for the state differs from the title and country in that a SPAN is used in conjunction with some javascript instead of INPUT with a bunch of OPTIONs. So I understand that it *needs* to be different, but it's the how that confuses me.

For example, all the copybilling.js examples I've seen here say

Code:

change_states(document.getElementById('s_country'), 's_state', 'State/Province', '', '', '', '');

Why does it reference s_country? I thought we were changing the state!

Also, I thought change_states had 10 args, but the example above supplies 7 .

Finally, why "State/Province" ? It appears from looking at change_states_js.tpl that the 3rd arg is supposed to be the County (which I don't happen to use).

Anyway, I can't really complain, because it all seems to work, but there's nothing that upsets my apple cart worse than something that looks like it shouldn't work, but does. :?

Griff

polkadot 06-16-2005 10:07 AM

@Griff:

Nice rollup onf information. I implemented it on 4.0.13 and everything seems to be working with one exception.

When checking the boxes everything works except the 'title' does not get copied and actually makes the destination 'title' field blank.

I looked to make sure there were no typos in the javascript for the field names and there don't seem to be any. Not sure why it doesnt work.

Anyone have any insight?

polkadot 06-16-2005 10:50 AM

I figured it out and now the title is working along with everything else.

I had to modify the source slightly for the title fields in register_ personal/billing/shipping _address.tpl

register_personal_address.tpl:

Find:
Code:

<OPTION {if $userinfo.title eq $name_titles[title]}selected{/if}>{$name_titles[title]}</OPTION>

Replace with:
Code:

<OPTION{if $userinfo.title eq $name_titles[title]} selected{/if} value="{$name_titles[title]}">{$name_titles[title]}</OPTION>


For register_billing_address.tpl:

Find:
Code:

<OPTION {if $userinfo.b_title eq $name_titles[title]}selected{/if}>{$name_titles[title]}</OPTION>

Replace with:
Code:

<OPTION{if $userinfo.b_title eq $name_titles[title]} selected{/if} value="{$name_titles[title]}">{$name_titles[title]}</OPTION>


For register_shipping_address.tpl:

Find:
Code:

<OPTION {if $userinfo.s_title eq $name_titles[title]}selected{/if}>{$name_titles[title]}</OPTION>

Replace with:
Code:

<OPTION{if $userinfo.s_title eq $name_titles[title]} selected{/if} value="{$name_titles[title]}">{$name_titles[title]}</OPTION>


All times are GMT -8. The time now is 10:23 AM.

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