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)

GriffithLea 06-17-2005 11:51 AM

Outstanding! I think they call this "collaboration". :D

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

r.jones 06-18-2005 06:58 AM

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>


cconway 06-21-2005 06:37 AM

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!

cashopoly 06-30-2005 01:27 PM

GriffithLea and polkadot...

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

Thanks.

cphillips 06-30-2005 01:36 PM

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

robble 07-04-2005 12:14 PM

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

mmoskva 08-02-2005 12:05 PM

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

cherie 08-07-2005 06:49 PM

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! :)

HWT 08-20-2005 07:24 AM

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

cherie 08-20-2005 07:57 AM

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.

HWT 08-20-2005 08:29 AM

cherie,

Thank you for your reply.

The two imput lines are inside a form.
Form Name: name="registerform"
Verified the script blocks in home.tpl
Verified that the js files exist in skin1

This is what show up on the line in the source that is throwing the 1st error:

Code:

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



and here is the line that throws the 2nd error:

Code:

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



Unfortunatley, I'm a little too much of a noob to js to get what your referring to as "script blocks", but I hope the above information answers your post completely. Unfortunately, no resolution yet.

Thanks again.

cherie 08-20-2005 08:39 AM

Quote:

Originally Posted by HWT
Verified the script blocks in home.tpl

Unfortunatley, I'm a little too much of a noob to js to get what your referring to as "script blocks"

When you view the page source for the page that has the errors (using your browser's View Source option), do you see the following script blocks?
Code:

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

In place of $SkinDir you might see /xcart/skin1... Can you then load that path in your browser location and see the contents of the js file? Just trying to make sure the Javascript functions in those files are available.

HWT 08-20-2005 08:56 AM

Gottcha! OK, I think we're getting somewhere here. The script blocks are not showing up in the <HEAD> tags. Funny, because I have one other js that is showing up there. The js is accessible from /skin1/copybilling.js

cherie 08-20-2005 09:08 AM

Quote:

Originally Posted by HWT
Gottcha! OK, I think we're getting somewhere here. The script blocks are not showing up in the <HEAD> tags. Funny, because I have one other js that is showing up there. The js is accessible from www.heritagetoys.com/skin1/copybilling.js

That appears to be the problem. If you added those script blocks to home.tpl, maybe you aren't using home.tpl? You'll need to sort that part out yourself. The idea is that you want to put those script blocks in a main tpl so it can be referenced by your checkboxes. Are you really using your cart at the root level (/) and not a cart directory (i.e., /xcart)? It's fine to do that, just verifying since you mentioned /skin1 and not /xcart/skin1.

HWT 08-20-2005 09:15 AM

Those two script blocks do show up on pages that don't use them like the home page. I'm using easy checkout. So I'm sure that's the issue. This page is probably not using home.tpl.

Yes, I have the cart installed at the root level. A lot of posts I read suggested it. This is the most succinct: http://forum.x-cart.com/viewtopic.php?t=21581&highlight=root

{* edit *}
For anyone using Jon's Easy Checkout Mod, add the code below to customer/home_checkout.tpl instead of customer/home.tpl when using GriffithLea's mod:

right below
Code:

</TITLE>
{ include file="meta.tpl" }
<LINK rel="stylesheet" href="{$SkinDir}/{#CSSFile#}">



add in
Code:

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


{* end edit *}

Thank you VERY much for your help in tracking this down. You may have just saved my sanity! :D

shan 11-29-2005 09:21 AM

it seems that people would have got errors with this if they had this setting unchecked

Quote:

Use JavaScript version for state and country selector:

anyone come up with anything for this ?

cotc2001 11-29-2005 09:47 AM

just an idea for the checkbox if shipping address different - wouldnt it be a good idea that the checkbox and option to send to seperate shipping address be good if it could be controlled by country.

i.e i'd be happy to send to a different address in the UK but doing that to somewhere like singapore would be a big no no.

At least in the UK i could send the boys round if it was fraud.

HWT 12-03-2005 05:22 AM

Recently I've gotten a huge number of calls from customers using Macintosh computers who can't change the state dropdown menu, and can't change the expiration date dropdowns during checkout. I've tracked it down to this mod being the possible culprit. Has anyone else been having this issue?

I did modify copynames.js and copybilling.js very slightly to not use the title, as we don't use it in our store:

copynames.js
Code:

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

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


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;
    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_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;
  }
}


I'm pretty sure that's not the issue, though. Anybody see anything in here that could cause a Mac to choke? I know nothing about Macs unfortunately, and have no way of testing either. :(

Any help would be appreciated. Thanks!!

cherie 12-03-2005 11:37 AM

Since x-cart uses different registration forms whether the customer is in the cart or not, copybilling.js needs to account for the differences.

This is what I ended up using for copybilling.js:
Code:

function InitSaveVariables_shippingC(form) {
  //s_title = form.s_title.value;
  s_title = form.s_title.selectedIndex
  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 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 copybillingC(form) {
  if (form.copyb.checked) {
    InitSaveVariables_shippingC(form);
    //form.s_title.value = form.b_title.value;
    form.s_title.selectedIndex = form.b_title.selectedIndex
    form.s_firstname.value = form.b_firstname.value;
    form.s_lastname.value = form.b_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_title.selectedIndex = 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;
  }
}

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


Then I used the following in main/register_shipping_address:
Code:

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


And I use the following in main/register_billing_address.tpl:
Code:

{* ======== COPY NAMES TO BILLING MOD ======= *}
{if $js_enabled}
<TR>
<TD align="right"></TD>
<TD></TD>
<TD nowrap>
<input type="checkbox" name="copyn" onclick="copynames(this.form);">Use {$lng.lbl_personal_information} in {$lng.lbl_billing_address}


</TD>
</TR>
{/if}
{* ======== COPY NAMES TO BILLING MOD ======= *}


ortonceramic 12-07-2005 06:28 AM

hack disables email fields?
 
I'm not certain that this mod has changed this, but now my email registration notification only shows:

Quote:

Personal information
Username: test1
Password: ****
First Name: Test
Last Name: Tested!
Company: Test, Inc.



When it should also be showing address, contact info, etc. Did some inane variable get changed with this mod??

Thanks!

mattw 02-08-2006 10:08 PM

has anyone figured out how to get this mod to work with additional fields in billing/shipping info?

cherie 02-08-2006 10:16 PM

Quote:

Originally Posted by mattw
has anyone figured out how to get this mod to work with additional fields in billing/shipping info?

I can't think off the top of my head why this would be a problem. Are you trying to include additional fields in what gets copied? Or are you seeing some other error?

mattw 02-08-2006 10:25 PM

im trying to include additional fields in the copy

cherie 02-08-2006 10:43 PM

Quote:

Originally Posted by mattw
im trying to include additional fields in the copy

I haven't done this yet, but you should just need to add the lines to the javascript code. First find out which fields you want to copy and to where. A good way to do this is to look at the page's source code. Here are two sample methods that should both work:
Code:

// get additional fields by their id
var addField2 = document.getElementById('additional_values_2')
var addField3 = document.getElementById('additional_values_3')
addField2.value = addField3.value

Code:

// values from numbered form elements
form.elements[5].value = form.elements[6].value

The first example uses the id parameter of the input field. Mine looks like this:
Code:

<INPUT type="text" name="additional_values[2]" id="additional_values_2" size="32">
The second example gets the value by explicitly identifying which input element in the form has the value. You have to count the form elements starting with 0 to find this. It might take some trial and error and maybe using alert(form.elements[5].name) to help you identify the field you are trying to use.

mattw 02-09-2006 06:06 AM

Quote:

A good way to do this is to look at the page's source code.

thank you, i dont know why i didnt think of that

mattw 02-09-2006 06:49 AM

so this is what i ended up with in copybilling.js
Code:

function InitSaveVariables_shipping(form){
additional_values_5 = form.additional_values_5.value;
additional_values_6 = form.additional_values_6.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.additional_values_5.value = form.additional_values_2.value;
form.additional_values_6.value = form.additional_values_3.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.additional_values_5.value = "";
  form.additional_values_6.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 = "";
  }
}


btomasie 03-10-2006 03:55 AM

I successfully implemented this in a 4.0.14 store that I did. But I am now doing another store, and it's in 4.0.17. I wasn't able to simply copy the same stuff over and get everything to work correctly. Having the name copied to the billing part works fine, but when I check the box to move the billing fields into the shipping fields, I get an error. It unfortunately doesn't give me much to go on, on where to troubleshoot.

So, has anyone successfully get this to work in v4.0.17 ? Or, I guess more importantly, what has changed between versions that I might be able to rework this myself?

***EDIT***
I went back into my store with Friefox and enabled the Javascript Console. It gives me a detailed error message now:

Error: document.getElementById("_s_state") has no properties
Source File: http://www.xxxxxxxxx.com/skin1/copybilling.js
Line: 10

In the copybilling.js file, this is line 10:
_s_state = document.getElementById('_s_state').value;


I have copied and pasted the javascript I am using from redlime's example.

Thanks!
Brian

rorktor1 03-27-2006 08:01 AM

Has anyone tried to get this working with the County field? Country works fine, but County is giving me problems. Not sure what to do.

dankind 03-27-2006 01:07 PM

This mod rocks :)

Also can do a onblur if needed. I didn't want a check box so I removed the checkbox and ran a little onblur js function to copy each field as the user enters it...Probably not useful for most stores, but very much needed for mine :)

fhiremark 05-01-2006 12:03 PM

Hello, I tried to sort thru all the snippets of code to try to get this working for x-cart gold v4.0.18 but no luck.

Can somebody who's using this mod on v4.0.18 help on what needs to be done and where? Thank You.

taltos1 05-31-2006 02:35 PM

I as well am very interested in an update on 4.0.18? Anyone got this working?
Thanks

cherie 05-31-2006 02:41 PM

Quote:

Originally Posted by taltos1
I as well am very interested in an update on 4.0.18? Anyone got this working?s

Yep, this is working on 4.0.18. :D

taltos1 05-31-2006 03:10 PM

I got the following to work in 4.0.18, and I am using the exCheckout Mod, however it only works during the checkout part, and not the "register" part, I read and reread all the posts but I am at a lose as to how to make this work there as well?

Any ideas?

Thanks a lot

Quote:

Originally Posted by DogByteMan
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 ======= *}



cherie 05-31-2006 03:13 PM

Quote:

Originally Posted by taltos1
I got the following to work in 4.0.18, and I am using the exCheckout Mod, however it only works during the checkout part, and not the "register" part, I read and reread all the posts but I am at a lose as to how to make this work there as well?

Do you have any more details on what is not working? Have you used Firefox's Javascript Console to see if you get any errors? I find it invaluable when troubleshooting Javascript. :D

taltos1 06-01-2006 08:16 PM

Hmm. There are numerous it seems there are about 20-30 "unknown properties" is that right? Hmm.... I am not to familiar with this console, can you point me in the right direction.. THanks so much!

cherie 06-01-2006 08:29 PM

Quote:

Originally Posted by taltos1
Hmm. There are numerous it seems there are about 20-30 "unknown properties" is that right? Hmm.... I am not to familiar with this console, can you point me in the right direction.. THanks so much!

Click on Errors at the top to just show the errors (red items). It should give some more detail, such as what is triggering that error. My first thought is that the .js file is not loading or the function/property names you are referencing are incorrect. If you post or PM the web site then I'll take a look. :D

thundernugs 08-19-2006 12:17 AM

i've read through the posts for this mod, it seems folks are still having errors when trying to apply this to 4.0.18, without the ez checkout mod. are the problems occurring only for visitors with macs?

i was about to go through this mod, but since we sell lots of items that are specific to the macs, it would seem like a bad idea.

are there any other options to reduce the triple name entry?

thanks!

ecommerce 09-06-2006 10:17 PM

Re: check box for "same as billing address"
 
does anybody got it successfully working on 4.0.18 with jons easy checkout?

i need it to work with ez checkout and on ie, safari, mozilla, firefox, netscape.

id be happy to test urs also.

dfawdon 12-03-2006 01:15 AM

Re: check box for "same as billing address"
 
Quote:

Originally Posted by ecommerce
does anybody got it successfully working on 4.0.18 with jons easy checkout?

i need it to work with ez checkout and on ie, safari, mozilla, firefox, netscape.

id be happy to test urs also.


I have this working now with Jon's Easy Checkout, my version is 4.0.17, I used the post by taltos1 for insrtuctions, but amended the copybilling2.js as Firefox was not copying the details across from the standard register page, it was ok in the checkout.

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


2coolbaby 02-26-2007 01:47 PM

Re: check box for "same as billing address"
 
I used this with taltos1's instructions except for copybilling2.js, which was provided from dfawdon above. I own a mac & it is working wonderfully for me! I just wanted to let anyone who might be holding off due to the previous mac issue know.


All times are GMT -8. The time now is 08:43 PM.

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