| 1 |
jQuery(document).ready(function($) { |
| 2 |
|
| 3 |
function localize_address_fields(address_type) { |
| 4 |
/* Hide custom NL fields by default when country not NL */ |
| 5 |
var country = $('#' + address_type + '_country').val(); |
| 6 |
if (typeof country != 'undefined') { |
| 7 |
if (country != 'NL') { |
| 8 |
$('#' + address_type + '_street_name_field').hide(); |
| 9 |
$('#' + address_type + '_house_number_field').hide(); |
| 10 |
$('#' + address_type + '_box_number_field').hide(); |
| 11 |
$('#' + address_type + '_address_1_field').show(); |
| 12 |
$('#' + address_type + '_address_2_field').show(); |
| 13 |
} else { |
| 14 |
$('#' + address_type + '_street_name_field').show(); |
| 15 |
$('#' + address_type + '_house_number_field').show(); |
| 16 |
$('#' + address_type + '_box_number_field').show(); |
| 17 |
$('#' + address_type + '_address_1_field').hide(); |
| 18 |
$('#' + address_type + '_address_2_field').hide(); |
| 19 |
} |
| 20 |
} |
| 21 |
} |
| 22 |
|
| 23 |
localize_address_fields('billing'); |
| 24 |
localize_address_fields('shipping'); |
| 25 |
|
| 26 |
$('#billing_country, #shipping_country').change(function() { |
| 27 |
id = $(this).attr('id'); |
| 28 |
address_type = id.replace('_country', ''); |
| 29 |
localize_address_fields(address_type); |
| 30 |
}); |
| 31 |
|
| 32 |
}); |
| 33 |
|