Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

check box for "same as billing address"

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #81  
Old 06-17-2005, 11:51 AM
  GriffithLea's Avatar 
GriffithLea GriffithLea is offline
 

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

Default

Outstanding! I think they call this "collaboration".

Supposedly, the default of VALUE is the content of the OPTION, which must be why it wasn't coded your way in the first place. It must be that some browsers (IE?) don't honor this default. I did my testing with Mozilla, so I didn't see the problem. I'm sort of glad that I didn't; it might have discouraged me from implementing my mod.

I tried without your fix on IE, and it gave me the same problem you saw. So I applied your fix, and all is well now.

By the way, you said "register_billing_info.tpl" and "register_shipping_info.tpl" - I think you meant "register_billing_address.tpl" and "register_shipping_address.tpl" . I knew what you meant, but conceivably someone out there might not.

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
  #82  
Old 06-18-2005, 06:58 AM
 
r.jones r.jones is offline
 

Newbie
  
Join Date: May 2005
Posts: 5
 

Default

This is a revision of the code I posted in this thread on May 18th, 2005. It addresses two problems with the original code:

1) An onBlur event isnБ─≥t executed under every circumstance (using the enter key instead of selecting the formБ─≥s submit button). So this has been removed and the data is now moved by the check_registerform_fields() function.

2) If the user has disabled javascript, the b_firstname and b_lastname fields remain empty the first time the form is submitted. This causes an error message that the user canБ─≥t correct because the fields are hidden. If the form is submitted again it will work because the fields contain firstname and lastname data that are now in the database from the first submission. So, now I only hide the fields when the javascript option is enabled. People that don't use javascript will have to do some extra typing.

Note: This still doesn't address the scenario of javascript being disabled and the user hasn't selected the Б─°If Javascript is disabled in your browser click hereБ─² option. They would still get an error message, but nothing would indicate what the problem is. Good enough for my purposes, but there is still room for improvement.

This is the code IБ─≥m currently using:

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 if javascript is enabled by changing main/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} {/if}

To:

Code:
{if $default_fields.firstname.avail eq 'Y'} {if $js_enabled} <INPUT type="hidden" name="b_firstname" size="32" maxlength="32" value="{$userinfo.firstname}"> {else} <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} {if $default_fields.lastname.avail eq 'Y'} {if $js_enabled} <INPUT type="hidden" name="b_lastname" size="32" maxlength="32" value="{$userinfo.lastname}"> {else} <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}

Step 4:

Add a four (lines end with a semi colon) lines to the check_registerform_fields() function in customer/main/register.tpl:

Original function:

Code:
<SCRIPT type="text/javascript" language="JavaScript 1.2"> var is_run = false; function check_registerform_fields() {ldelim} if(is_run) return false; is_run = true; if (check_zip_code(){if $default_fields.email.avail eq 'Y'} && checkEmailAddress(document.registerform.email, '{$default_fields.email.required}'){/if} {if $config.General.check_cc_number eq "Y" AND $config.General.disable_cc ne "Y"}&& checkCCNumber(document.registerform.card_number,document.registerform.card_type) {/if}&& checkRequired('')) {ldelim} document.registerform.submit(); return true; {rdelim} is_run = false; return false; {rdelim} </SCRIPT>

Revised function:

Code:
<SCRIPT type="text/javascript" language="JavaScript 1.2"> var is_run = false; function check_registerform_fields() {ldelim} {if $js_enabled} document.registerform.b_firstname.value = document.registerform.firstname.value; document.registerform.b_lastname.value = document.registerform.lastname.value; {/if} if(is_run) return false; is_run = true; if (check_zip_code(){if $default_fields.email.avail eq 'Y'} && checkEmailAddress(document.registerform.email, '{$default_fields.email.required}'){/if} {if $config.General.check_cc_number eq "Y" AND $config.General.disable_cc ne "Y"}&& checkCCNumber(document.registerform.card_number,document.registerform.card_type) {/if}&& checkRequired('')) {ldelim} document.registerform.submit(); return true; {rdelim} is_run = false; return false; {rdelim} </SCRIPT>
__________________
r.jones
X-Cart Version 4.0.13
Reply With Quote
  #83  
Old 06-21-2005, 06:37 AM
 
cconway cconway is offline
 

Member
  
Join Date: May 2005
Posts: 28
 

Default

Quote:
Originally Posted by r.jones
This is the code IБ─≥m currently using:

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 if javascript is enabled by changing main/register_billing_address.tpl starting at about line 28 from:

...

Step 4:

Add a four (lines end with a semi colon) lines to the check_registerform_fields() function in customer/main/register.tpl:

...

This works perfectly for me on X-Cart 4.0.13 Gold. Quick and easy changes.

Thanks r.jones!
__________________
X-Cart Gold 4.1.3 on Linux with
PHP 4.4.1, MySQL 4.0.25

Installed mods:
1. X-Cart 4 Level Vertical Flyout Menus for 4.1.x by
http://www.xcartmods.co.uk
2. XC SEO 1.1.5 by intel352
http://forum.x-cart.com/showthread.php?p=142953
Reply With Quote
  #84  
Old 06-30-2005, 01:27 PM
 
cashopoly cashopoly is offline
 

Newbie
  
Join Date: Jun 2005
Posts: 4
 

Default

GriffithLea and polkadot...

both your posts were very educational and helpful. I've implemented the code and it worked perfectly.

Thanks.
__________________
Cashopoly.com :: Build. Market. Sell.
Business Automation Made Simple.

X-Cart version 4.0.14
PHP 5.0.3
MySQL client 4.1.13
Reply With Quote
  #85  
Old 06-30-2005, 01:36 PM
 
cphillips cphillips is offline
 

Advanced Member
  
Join Date: May 2005
Location: Malvern, PA. USA
Posts: 73
 

Default cashopoly - do you have the steps you followed?

Cashopoly-

Do you have a list of steps you followed to make this work correctly? I tried without success.

Thanks
__________________
Thanks,

cphillips

Malvern, Pennsylvania
USA
Reply With Quote
  #86  
Old 07-04-2005, 12:14 PM
 
robble robble is offline
 

Newbie
  
Join Date: Apr 2005
Posts: 6
 

Default

I would like to personally thank all of you who have put in the time and commitment to make this work very well.

I have used Phil's original copybilling setup, in tandem with r. jones copy personal info to billing to create exactly what I want in XCART v. 4.0.13:

Personal info copies over to billing info.
Input button in bottom of billing info copies all billing data to shipping if wanted.
States selection works great.

Again, thanks very much to all of you who have contributed to this modification.

Todd
__________________
Wedding Planning Guide
Web Hosting

Version 4.0.13 [unix]
Reply With Quote
  #87  
Old 08-02-2005, 12:05 PM
 
mmoskva mmoskva is offline
 

eXpert
  
Join Date: Aug 2005
Location: Pennsylvania
Posts: 306
 

Default

Hello,

I was reading all the post and trying all of your ideas but I am having trouble putting everything together. Can someone be kind enough to help me out with steps, on what to do?

Thanks
__________________
x-cart 4.0.16v
linux server
Reply With Quote
  #88  
Old 08-07-2005, 06:49 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default

Great work by all who have contributed to this. It's made for a nice enhancement that should be part of the cart out of the box.

Note that the patch mentioned in step 2 above is already in place in 4.0.14, so it should only be necessary pre-14.

I made a slight change to which fields are copied and when. When the fields are copied from billing to shipping I copy the title and name from billing instead of from the name section. This seems to make more sense to me.

I also copied the copybilling function so it can also be used on the regular registration screen (the latest steps here seem to be setup for the anonymous checkout registration form). The modified function simply excludes the copying of title and name. So I use the following in main/register_shipping_address.tpl
Code:
{if $action ne "cart"} {* ======== COPY BILLING TO SHIPPING MOD ======= *} {if $js_enabled} <TR> <TD align="right"></TD> <TD></TD> <TD nowrap> <input type="checkbox" name="copyb" onclick="copybilling(this.form);">Use {$lng.lbl_billing_address} as {$lng.lbl_shipping_address} </TD> </TR> {/if} {* ======== COPY BILLING TO SHIPPING MOD ======= *} {elseif $action eq "cart"} {* ======== COPY BILLING TO SHIPPING MOD ======= *} {if $js_enabled} <TR> <TD align="right"></TD> <TD></TD> <TD nowrap> <input type="checkbox" name="copyb" onclick="copybillingC(this.form);">Use {$lng.lbl_billing_address} as {$lng.lbl_shipping_address} </TD> </TR> {/if} {* ======== COPY BILLING TO SHIPPING MOD ======= *}
...where copybillingC is the function posted earlier and copybilling just removes the title/names:
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 = 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_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_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; } }
Also, it seems that copying the title from the popup menu was not working correctly on WinIE so I changed:
Code:
s_title = form.s_title.value
Code:
form.s_title.value = form.b_title.value
Code:
form.s_title.value = s_title
to:
Code:
s_title = form.s_title.selectedIndex
Code:
form.s_title.selectedIndex = form.b_title.selectedIndex
Code:
form.s_title.selectedIndex = s_title
This was very easy to implement. Thanks again!
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
  #89  
Old 08-20-2005, 07:24 AM
  HWT's Avatar 
HWT HWT is offline
 

eXpert
  
Join Date: Jan 2005
Location: Massachusetts, USA
Posts: 392
 

Default

Having trouble with the code posted by GriffithLea

I believe I've implemented it "by the book", but I get the Java Script error "Object expected" on this line:

Code:
<input type="checkbox" name="copyn" onclick="javascript:copynames(this.form);">Use Customer Details in Billing Address

and this line:

Code:
<input type="checkbox" name="copyb" onclick="javascript:copybilling(this.form);">Use Billing Address as Shipping Address

Any help solving this would be appreciated! TIA
__________________
x-cart 4.0.13 and 4.1.7 and 4.1.10
Reply With Quote
  #90  
Old 08-20-2005, 07:57 AM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default

Verify those two input lines are inside a form. See if your form has a name. Verify you included the script blocks in home.tpl:
Code:
<script language=JavaScript1.3 src="{$SkinDir}/copybilling.js"></script> <script language=JavaScript1.3 src="{$SkinDir}/copynames.js"></script>
Verify those js files exist in that location (i.e., /xcart/skin1/copynames.js). See if those script blocks show when viewing the page source while viewing the page that has the checkboxes.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:01 AM.

   

 
X-Cart forums © 2001-2020