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)

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


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


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:

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


// 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:

<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


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

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){
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?

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.


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.

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

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