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)

CopperB 02-08-2005 04:42 PM

Thanks for the reply DogByte but I cannot find this template.

Quote:

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>

Are you sure about the home_checkout.tpl?

Thanks

balinor 02-08-2005 04:50 PM

I believe the code posted by Dogbyteman only works if you have Jon's EzCheckout mod installed.

CopperB 02-08-2005 05:03 PM

Yep I'm going blind. Missed the reference to the ezCheckout mod by jon.

jeremy35 02-08-2005 10:58 PM

Quote:

Originally Posted by CC
jeremy35 you still got errors man.

Just checked it out on your site...


Yep, you're right...I missed the register issue. Thanks for the heads up.

Bradc 02-09-2005 08:15 AM

Hi all

Quick little hack so that the "Use Billing Address as Shipping Address" check box only shows up in anonymous check out and not in "create profile" (leave empty if same as billing address seems to work fine).

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


Hope this helps! :D

CopperB 02-09-2005 03:12 PM

Thanks Brad. works like a charm.

I am still wondering if anyone has done this with an " Additional " Phone field in Billing and Shipping at anonymous check out.

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

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

If needed the website (which is not live yet) is at: http://www.copperboppers.com/xcart/home.php

Thanks again. :D

torola 02-16-2005 12:24 PM

See message bellow

Tom

torola 02-17-2005 02:46 PM

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

Bella Forma 02-24-2005 06:55 PM

Just wanted to pop back and clarify something that was puzzling me and may puzzle others.

When I read this post initially a few people commented about the xcart default of 'leave empty if same as billing address' working just fine for version 4.0.*

I thought this was a bit odd as I am on version 4.0.11 and is wasn't showing so I presumed I must have messed it up when editing templates previously.

However today I decided to make my shipping fields 'not required' in the User Profile and lo and behold the 'leave empty if same as billing address' appears again and does indeed work just fine.

So you only have to use this mod if your shipping fields are required, unless of course you just prefer a checkbox.

Sorry if this is stating the obvious :lol:

torola 02-25-2005 09:32 AM

Yes, you are right Bella Forma,

but that works only on the registration page.

Once in cart, proceed to check out, here you don't have that option and everything needs to be entered separately.

Tom

Bella Forma 02-25-2005 01:21 PM

Ugggggh yes your right.... that's so stupid!!

Hmmm so it seems like putting the checkbox in IS the best thing to do then even on 4.0.* unless you want to really annoy your customers :wink:

Regarding the 'First Name' and 'Last Name' fields in Billing/Shipping Address (in the cart form) has anyone just hidden/commented them out? Does this cause any problems with the registratioin process from the cart?

Cheers,

Nicki

CopperB 03-07-2005 05:35 PM

Nicki

Quote:

Regarding the 'First Name' and 'Last Name' fields in Billing/Shipping Address (in the cart form) has anyone just hidden/commented them out? Does this cause any problems with the registratioin process from the cart?

I found this post that shows you how to hide these fields. I have not tried it myself though. Hope this helps.

http://forum.x-cart.com/viewtopic.php?t=17146&highlight=profile


Hope this helps.

CopperB 03-07-2005 05:44 PM

I have this MOD working on my sire right now but wanted to change it a little bit.

Rather than have the "check box" show up at the bottom of the skin1/main/register_billing_address.tpl I would like to put it at the top of the skin1/main/register_shipping_address.tpl except I don't know java at all and am not sure what to change in this code so it pulls the info from the register_billing_info.

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


Any Java experts out there?

Bella Forma 03-07-2005 07:43 PM

Thanks for the link CopperB I hadn't seen that post, will put it on my pile of things to do... which never seems to get any smaller!!

As one good turn deserves another....

Regarding the javascript changes you shouldn't need to make any.

Just cut and paste the code in your message from register_billing_address.tpl to register_shipping_address.tpl and as long as you don't have both checkboxes and your calling the javascript from the customer/home.tpl as described earlier the javascript will work exactly the same as before.

CopperB 03-08-2005 03:25 PM

Thanks Nicki,

Quote:

as long as you don't have both checkboxes

That was the problem. When I was testing it I had the checkbox code in both the billing and shipping templates. I removed from the billing template and it is working properly.

CopperB 03-09-2005 03:28 PM

I am wanting to make this mod a little neater by changing it to a Button (instead of the checkbox) that says "Same as Billing" on the button.

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




{* ======== 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 am not sure what I need to change in the code to get it to say Same as Billing on the button itself. I know the input type is changed to Button but can't figure out how to get the text on the button itself. Changing name="copyb" to Same as Billing did not work for me.

Any help is appreciated.

torola 03-10-2005 04:31 AM

Instead of

<input type="checkbox" name="copyb" onclick=javascript:copybilling(this.form);>Use {$lng.lbl_billing_address} as {$lng.lbl_shipping_address}



Try tu put this
<input type="submit" name="copyb" value="Shipping same as Billing" onclick=javascript:copybilling(this.form);>

bbanzai 03-10-2005 12:35 PM

check box for "same as billing address"
 
Thank heaven for this form. I am not a developer so you guys are a great help to me.

For those who have added the check box and can't get the user data to show up in the billing section for Mozzilla, but works in IE....


Add quotes around to the javascript call , as follows:

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

Bella Forma 03-21-2005 02:18 PM

I thought about this whole first name/last name thing a bit more and decided that there may well be times when the billing and shipping names are different to the original registered names. My theory being that I sometimes use my other halfs card to purchase online and if I was sending it to someone else as a present then that would be three sets of names.

Anyway I decided to keep the names fields visible but implement an additional checkbox for the name copying that copies the title, first and last names from personal info into billing and shipping info. Taking out the names copying lines in the original copybilling script and adding this copyname script instead.

Code:

function InitSaveVariables_name(form){
title = form.title.options[form.title.options.selectedIndex].value;
firstname = form.firstname.value;
lastname = form.lastname.value;
}

function copyname(form){
if (form.copyn.checked){
InitSaveVariables_name(form);
form.b_title.options.selectedIndex = form.title.options.selectedIndex;
form.b_firstname.value = firstname;
form.b_lastname.value = lastname;
form.s_title.options.selectedIndex = form.title.options.selectedIndex;
form.s_firstname.value = firstname;
form.s_lastname.value = lastname;
}

else {
  form.b_title.options.selectedIndex = 0;
  form.s_title.options.selectedIndex = 0;
  form.b_firstname.value = "";
  form.b_lastname.value = "";
  form.s_firstname.value = "";
  form.s_lastname.value = "";
  }
}


The script is used in exactly the same way as the original copybilling so you need to add a checkbox called 'copyn' and call the javascript 'copyname.js' in the home.tpl as described previously in this post.

Hope that helps someone else.

Nicki

dgrif 04-14-2005 06:55 PM

Hi,
Thank you for this help as my customers would not use this site because of the shipping problem. They always went back to the old site to order.
Maybe someone would have the answer for another problem I have with shipping. I had someone do a drop down box so it would automatically revert to the cheapest shipping method. It does that but it won't give them the option of choosing UPS as another method of shipping. If it's 1 dvd it cost $2.00 to ship that will automatically show up but if they want to choose ups it will not allow them to change to that method.

Delores

usiripakdi 04-19-2005 09:27 AM

I can't get anything to work. When I click on "Use Billing Address as Shipping Address" I get "Error on Page"

Here is the code. Somebody Help!!

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



home.tpl
Code:

{* $Id: home.tpl,v 1.67.2.6 2004/12/01 15:15:48 mclap Exp $ *}
{if $printable ne ''}
{include file="customer/home_printable.tpl"}
{else}
{config_load file="$skin_config"}
<HTML>
<HEAD>
<TITLE>
{if $config.SEO.page_title_format eq "A"}
{section name=position loop=$location}
{$location[position].0|escape}
{if not %position.last%} :: {/if}
{/section}
{else}
{section name=position loop=$location step=-1}
{$location[position].0|escape}
{if not %position.last%} :: {/if}
{/section}
{/if}
</TITLE>
{ include file="meta.tpl" }
<LINK rel="stylesheet" href="{$SkinDir}/{#CSSFile#}">
<script language=JavaScript1.3 src="{$SkinDir}/copybilling.js"></script>

</HEAD>
<BODY leftmargin="0" topmargin="0" rightmargin="0" bottomargin="0" marginwidth="0" marginheight="0">
{ include file="rectangle_top.tpl" }
{ include file="head.tpl" }
{if $active_modules.SnS_connector}
{include file="modules/SnS_connector/header.tpl"}
{/if}

<TABLE border="0" width="100%" cellpadding="0" cellspacing="0" align="center">
<TR>
<TD class="left" width="170" valign="top">
{if $categories ne "" and ($active_modules.Fancy_Categories ne "" or $config.General.root_categories eq "Y" or $subcategories ne "")}
{ include file="customer/categories.tpl" }
{/if}
{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu eq "Y"}
{ include file="modules/Bestsellers/menu_bestsellers.tpl" }
{/if}
{if $active_modules.Manufacturers ne "" and $config.Modules.manufacturers_menu eq "Y"}
{ include file="modules/Manufacturers/menu_manufacturers.tpl" }
{/if}
{include file="customer/special.tpl"}
{ include file="help.tpl" }
[img]{$ImagesDir}/spacer.gif[/img]
</TD>
<TD width="20"></TD>
<TD valign="top">



{include file="dialog_message.tpl"}
{if $active_modules.Special_Offers ne ""}
{include file="modules/Special_Offers/customer/new_offers_message.tpl"}
{/if}
{include file="customer/home_main.tpl"}


</TD>
<TD width="20"></TD>
<TD class="right" width="170" valign="top">
{if $active_modules.SnS_connector}
{include file="modules/SnS_connector/button.tpl"}

{/if}
{if $active_modules.Feature_Comparison ne "" && $comparison_products ne ''}
{ include file="modules/Feature_Comparison/product_list.tpl" }
{/if}
{if $active_modules.Users_online ne ""}
{ include file="modules/Users_online/menu_users_online.tpl" }
{/if}
{ include file="customer/menu_cart.tpl" }
{if $login eq "" }
{ include file="auth.tpl" }
{else}
{ include file="authbox.tpl" }
{/if}
{ include file="news.tpl" }
{if $active_modules.Interneka ne ""}
{ include file="modules/Interneka/menu_interneka.tpl" }
{/if}
{ include file="poweredby.tpl" }
[img]{$ImagesDir}/spacer.gif[/img]
</TD>
</TR>
</TABLE>
{ include file="rectangle_bottom.tpl" }
</BODY>
</HTML>
{/if}


register_billing_address.tpl

Code:

{* $Id: register_billing_address.tpl,v 1.15.2.4 2005/03/09 11:44:27 max Exp $ *}
{if $default_fields.b_state.avail eq 'Y' && $default_fields.b_country.avail eq 'Y' && $js_enabled eq 'Y' && $config.Adaptives.isJS eq 'Y' && $config.General.use_js_states eq 'Y' && $config.Adaptives.isDOM eq 'Y'}{include file="change_states_js.tpl"}{/if}
{if $is_areas.B eq 'Y'}
{if $hide_header eq ""}
<TR>
<TD height="20" colspan="3">{$lng.lbl_billing_address}<HR size="1" noshade></TD>
</TR>
{/if}

{if $action eq "cart"}
<INPUT type="hidden" name="action" value="cart">
<INPUT type="hidden" name="paymentid" value="{$paymentid}">

{if $default_fields.title.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_title}</TD>
<TD>{if $default_fields.title.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<SELECT name="b_title">
{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>
{/if}

{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}
{/if}

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

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

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

{if $default_fields.b_state.avail eq 'Y' && $default_fields.b_country.avail eq 'Y' && $js_enabled eq 'Y' && $config.General.use_js_states eq 'Y'}
{include file="main/register_states.tpl" state_name="b_state" country_name="b_country" country=$userinfo.b_country state=$userinfo.b_state|default:$config.General.default_state full_state=$userinfo.b_statename county_name="b_county" default_county=$userinfo.b_countyname default_countyid=$userinfo.b_county form_name="registerform" zipcode_name="b_zipcode"}
{else}
{if $default_fields.b_county.avail eq 'Y' and $config.General.use_counties eq "Y"}
<TR>
<TD align="right">{$lng.lbl_county}</TD>
<TD>{if $default_fields.b_county.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
{include file="main/counties.tpl" counties=$counties name="b_county" default=$userinfo.b_county country_name="b_country"}
{if ($reg_error ne "" and $userinfo.b_county eq "" and $default_fields.b_county.required eq 'Y') or $error eq "b_county"}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{if $default_fields.b_state.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_state}</TD>
<TD>{if $default_fields.b_state.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
{include file="main/states.tpl" states=$states name="b_state" default=$userinfo.b_state default_country=$userinfo.b_country country_name="b_country"}
{if $error eq "b_statecode" and $default_fields.b_state.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{if $default_fields.b_country.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_country}</TD>
<TD>{if $default_fields.b_country.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<SELECT name="b_country" id="b_country" onChange="check_zip_code()">
{section name=country_idx loop=$countries}
<OPTION value="{$countries[country_idx].country_code}"{if $userinfo.b_country eq $countries[country_idx].country_code} selected{elseif $countries[country_idx].country_code eq $config.General.default_country and $userinfo.b_country eq ""} selected{/if}>{$countries[country_idx].country}</OPTION>
{/section}
</SELECT>
{if $reg_error ne "" and $userinfo.b_country eq "" and $default_fields.b_country.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{/if}

{if $default_fields.b_zipcode.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_zip_code}</TD>
<TD>{if $default_fields.b_zipcode.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="b_zipcode" name="b_zipcode" size="32" maxlength="32" value="{$userinfo.b_zipcode}" onChange="check_zip_code()" >
{if $reg_error ne "" and $userinfo.b_zipcode eq "" and $default_fields.b_zipcode.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{* ======== 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}
{include file="main/register_additional_info.tpl" section="B"}
{/if}




How matter how I chaged it. Still "Error on Page"
so frustrated.

dgrif 04-19-2005 09:31 AM

Did you go into admin and make the information required?
I had to do that to get mine to work.

Delores

usiripakdi 04-19-2005 09:40 AM

I made the change to make the shipping requirement same as the billing requirement. Still "Error on Page"

Check it out at my site
www.thaimediastore.com/home.php

dont' worry about the cart or register. It is still a testing site.

dgrif 04-19-2005 10:21 AM

Here is my code try this as mine does work
 
copybillin.js
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 = "";
}
}


home.tpl
{* $Id: home.tpl,v 1.67.2.6 2004/12/01 15:15:48 mclap Exp $ *}
{if $printable ne ''}
{include file="customer/home_printable.tpl"}
{else}
{config_load file="$skin_config"}
<HTML>
<HEAD>
<TITLE>
{if $config.SEO.page_title_format eq "A"}
{section name=position loop=$location}
{$location[position].0|escape}
{if not %position.last%} :: {/if}
{/section}
{else}
{section name=position loop=$location step=-1}
{$location[position].0|escape}
{if not %position.last%} :: {/if}
{/section}
{/if}
</TITLE>
{ include file="meta.tpl" }
<LINK rel="stylesheet" href="{$SkinDir}/{#CSSFile_c#}">
<script language=JavaScript1.3 src="{$SkinDir}/copybilling.js"></script>
{assign var="fancy_ie_background_color" value="78146E"}
{assign var="fancy_left" value="2"}

</HEAD>
<BODY leftmargin="0" topmargin="0" rightmargin="0" bottomargin="0" marginwidth="0" marginheight="0">
{ include file="rectangle_top.tpl" }
{ include file="head.tpl" }
{if $active_modules.SnS_connector}
{include file="modules/SnS_connector/header.tpl"}
{/if}

<TABLE border="0" width="100%" cellpadding="0" cellspacing="0" align="center">
<TR>
<TD width="3" class="VertMenuBox"></TD>
<TD width="171" valign="top" class="VertMenuBox">
{if $categories ne "" and ($active_modules.Fancy_Categories ne "" or $config.General.root_categories eq "Y" or $subcategories ne "")}
{ include file="customer/categories.tpl" }


{/if}
{if $active_modules.Bestsellers ne "" and $config.Modules.bestsellers_menu eq "Y"}
{ include file="modules/Bestsellers/menu_bestsellers.tpl" }
{/if}
{if $active_modules.Manufacturers ne "" and $config.Modules.manufacturers_menu eq "Y"}
{ include file="modules/Manufacturers/menu_manufacturers.tpl" }
{/if}
{include file="customer/special.tpl"}
{ include file="help.tpl" }
[img]{$ImagesDir}/spacer.gif[/img]
</TD>
<TD width="10"></TD>
<TD valign="top">

{include file="location.tpl"}

{include file="dialog_message.tpl"}

{if $active_modules.Special_Offers ne ""}
{include file="modules/Special_Offers/customer/new_offers_message.tpl"}
{/if}

{include file="customer/home_main.tpl"}


</TD>
<TD width="10"></TD>
<TD width="171" valign="top" class="VertMenuBox">
{if (($main eq 'catalog' && $cat ne '') || $main eq 'product') && $config.Appearance.enabled_printable_version eq 'Y'}
<DIV align="center">
{include file="printable.tpl"}
</DIV>


{/if}
{include file="customer/search.tpl"}


{if $active_modules.SnS_connector}
{include file="modules/SnS_connector/button.tpl"}



{/if}
{if $active_modules.Feature_Comparison ne "" && $comparison_products ne ''}
{ include file="modules/Feature_Comparison/product_list.tpl" }


{/if}
{if $active_modules.Users_online ne ""}
{ include file="modules/Users_online/menu_users_online.tpl" }


{/if}
{ include file="customer/menu_cart.tpl" }


{if $login eq "" }
{ include file="auth.tpl" }


{else}
{ include file="authbox.tpl" }


{/if}


{ include file="news.tpl" }
{if $active_modules.Interneka ne ""}


{ include file="modules/Interneka/menu_interneka.tpl" }
{/if}


{ include file="poweredby.tpl" }


[img]{$ImagesDir}/spacer.gif[/img]
</TD>
</TR>
</TABLE>
{ include file="rectangle_bottom.tpl" }
</BODY>
</HTML>
{/if}


register_billing_address.tpl
{* $Id: register_billing_address.tpl,v 1.15.2.4 2005/03/09 11:44:27 max Exp $ *}
{if $default_fields.b_state.avail eq 'Y' && $default_fields.b_country.avail eq 'Y' && $js_enabled eq 'Y' && $config.Adaptives.isJS eq 'Y' && $config.General.use_js_states eq 'Y' && $config.Adaptives.isDOM eq 'Y'}{include file="change_states_js.tpl"}{/if}
{if $is_areas.B eq 'Y'}
{if $hide_header eq ""}
<TR>
<TD height="20" colspan="3">{$lng.lbl_billing_address}<HR size="1" noshade></TD>
</TR>
{/if}
{if $action eq "cart"}
<INPUT type="hidden" name="action" value="cart">
<INPUT type="hidden" name="paymentid" value="{$paymentid}">
{if $default_fields.title.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_title}</TD>
<TD>{if $default_fields.title.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<SELECT name="b_title">
{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>
{/if}

{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}
{/if}

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

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

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

{if $default_fields.b_state.avail eq 'Y' && $default_fields.b_country.avail eq 'Y' && $js_enabled eq 'Y' && $config.General.use_js_states eq 'Y'}
{include file="main/register_states.tpl" state_name="b_state" country_name="b_country" country=$userinfo.b_country state=$userinfo.b_state|default:$config.General.de fault_state full_state=$userinfo.b_statename county_name="b_county" default_county=$userinfo.b_countyname default_countyid=$userinfo.b_county form_name="registerform" zipcode_name="b_zipcode"}
{else}
{if $default_fields.b_county.avail eq 'Y' and $config.General.use_counties eq "Y"}
<TR>
<TD align="right">{$lng.lbl_county}</TD>
<TD>{if $default_fields.b_county.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
{include file="main/counties.tpl" counties=$counties name="b_county" default=$userinfo.b_county country_name="b_country"}
{if ($reg_error ne "" and $userinfo.b_county eq "" and $default_fields.b_county.required eq 'Y') or $error eq "b_county"}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{if $default_fields.b_state.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_state}</TD>
<TD>{if $default_fields.b_state.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
{include file="main/states.tpl" states=$states name="b_state" default=$userinfo.b_state default_country=$userinfo.b_country country_name="b_country"}
{if $error eq "b_statecode" and $default_fields.b_state.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}

{if $default_fields.b_country.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_country}</TD>
<TD>{if $default_fields.b_country.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<SELECT name="b_country" id="b_country" onChange="check_zip_code()">
{section name=country_idx loop=$countries}
<OPTION value="{$countries[country_idx].country_code}"{if $userinfo.b_country eq $countries[country_idx].country_code} selected{elseif $countries[country_idx].country_code eq $config.General.default_country and $userinfo.b_country eq ""} selected{/if}>{$countries[country_idx].country}</OPTION>
{/section}
</SELECT>
{if $reg_error ne "" and $userinfo.b_country eq "" and $default_fields.b_country.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{/if}
{/if}

{if $default_fields.b_zipcode.avail eq 'Y'}
<TR>
<TD align="right">{$lng.lbl_zip_code}</TD>
<TD>{if $default_fields.b_zipcode.required eq 'Y'}<FONT class="Star">*</FONT>{else}{/if}</TD>
<TD nowrap>
<INPUT type="text" id="b_zipcode" name="b_zipcode" size="32" maxlength="32" value="{$userinfo.b_zipcode}" onChange="check_zip_code()" >
{if $reg_error ne "" and $userinfo.b_zipcode eq "" and $default_fields.b_zipcode.required eq 'Y'}<FONT class="Star">&lt;&lt;</FONT>{/if}
</TD>
</TR>
{* ======== 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}
{include file="main/register_additional_info.tpl" section="B"}
{/if}


Hope this helps
Delores

usiripakdi 04-19-2005 03:16 PM

I am sorry but it still doesn't solve the problem. Got "Error on page" plus
all the bottons and menus doesn't display properly.

Check it out at the site
www.thaimediastore.com/home.php

dgrif 04-19-2005 03:23 PM

There is something wrong with your site and the check button doesn't have anything to do with it. It's not displaying properly.
It's going to take someone that's knows more than I do to fix it.


Delores

dgrif 04-19-2005 03:32 PM

Hi,
Go to general setting and make sure this box is not checked
When a customer isn't logged in, it is presumed that he is from the default country.:


Delores

usiripakdi 04-19-2005 04:16 PM

Yes, I checked that and I also checked every line of your code and my code. It is identical. So, I am bummed. :(

bestdata 04-20-2005 09:08 AM

check box for "same as billing address"
 
did u try this ?

<script language=JavaScript1.3 src="/templates/skin1/copybilling.js">

needs to be added to the home.tpl in the templates/skin1/customer

just before </head>

usiripakdi 04-20-2005 12:05 PM

Yes try to change that line from

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

to

<script language=JavaScript1.3 src="/skin1/copybilling.js"></script>

still doesn't work

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:09 AM.

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