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!
