View Single Post
  #77  
Old 06-15-2005, 07:47 PM
  GriffithLea's Avatar 
GriffithLea GriffithLea is offline
 

Member
  
Join Date: Jun 2005
Location: Houston, TX
Posts: 28
 

Default

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
__________________
Started out with Version 4.0.13 .
Upgraded to Version 4.0.14 on 27 Jun 2005 .
Upgraded to Version 4.0.17 on 04 Dec 2005 .
Upgraded to Version 4.0.19 on 24 Oct 2006 .
Reply With Quote