You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 11, 2022. It is now read-only.
The code currently only set the parameter to the initial value of the Shipping/Billing country. It should update each time the country is changed. I took the liberty of fixing. Here is the updated postcode-checkout.phtml
isPostcodeAutocompleteEnabled()): ?>
<script type="text/javascript">
var citySuggestUrl = 'helper('australia')->getCitySuggestUrl(); ?>';
//============ Billing ============//
var autocomplete_city_billing = new Element('div', { id: 'autocomplete_city_billing', 'class': 'fontis-postcode-autocomplete' });
var billing_completer;
var shipping_completer;
if ($('billing:city')) {
$('billing:city').parentNode.appendChild(autocomplete_city_billing);
function updateAddressBilling(text, item) {
// Update state and postcode fields
var id = item.id;
var tokens = id.split('-');
// Assume item at index 1 is region_id, item at index 3 is postcode
$('billing:region_id').value = tokens[1];
$('billing:postcode').value = tokens[3];
}
// Create the autocompleter and assign it to a variable for future use.
billing_completer = new Ajax.Autocompleter("billing:city", "autocomplete_city_billing", citySuggestUrl, {
afterUpdateElement: updateAddressBilling,
minChars: 2,
parameters: 'country=' + $F('billing:country_id')
});
}
$('billing:country_id').observe('change', function(event) {
billing_completer.options.defaultParams = 'country=' + $F('billing:country_id');
});
//============ Shipping ============//
var autocomplete_city_shipping = new Element('div', { id: 'autocomplete_city_shipping', 'class': 'fontis-postcode-autocomplete' });
if ($('shipping:city')) {
$('shipping:city').parentNode.appendChild(autocomplete_city_shipping);
function updateAddressShipping(text, item) {
// Update state and postcode fields
var id = item.id;
var tokens = id.split('-');
// Assume item at index 1 is region_id, item at index 3 is postcode
$('shipping:region_id').value = tokens[1];
$('shipping:postcode').value = tokens[3];
}
// Create the autocompleter and assign it to a variable for future use.
shipping_completer = new Ajax.Autocompleter("shipping:city", "autocomplete_city_shipping", citySuggestUrl, {
afterUpdateElement: updateAddressShipping,
minChars: 2,
parameters: 'country=' + $F('shipping:country_id')
});
}
$('shipping:country_id').observe('change', function(event) {
shipping_completer.options.defaultParams = 'country=' + $F('shipping:country_id');
});
</script>
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The code currently only set the parameter to the initial value of the Shipping/Billing country. It should update each time the country is changed. I took the liberty of fixing. Here is the updated postcode-checkout.phtml
isPostcodeAutocompleteEnabled()): ?> <script type="text/javascript"> var citySuggestUrl = 'helper('australia')->getCitySuggestUrl(); ?>'; //============ Billing ============// var autocomplete_city_billing = new Element('div', { id: 'autocomplete_city_billing', 'class': 'fontis-postcode-autocomplete' }); var billing_completer; var shipping_completer; if ($('billing:city')) { $('billing:city').parentNode.appendChild(autocomplete_city_billing); function updateAddressBilling(text, item) { // Update state and postcode fields var id = item.id; var tokens = id.split('-'); // Assume item at index 1 is region_id, item at index 3 is postcode $('billing:region_id').value = tokens[1]; $('billing:postcode').value = tokens[3]; } // Create the autocompleter and assign it to a variable for future use. billing_completer = new Ajax.Autocompleter("billing:city", "autocomplete_city_billing", citySuggestUrl, { afterUpdateElement: updateAddressBilling, minChars: 2, parameters: 'country=' + $F('billing:country_id') }); } $('billing:country_id').observe('change', function(event) { billing_completer.options.defaultParams = 'country=' + $F('billing:country_id'); }); //============ Shipping ============// var autocomplete_city_shipping = new Element('div', { id: 'autocomplete_city_shipping', 'class': 'fontis-postcode-autocomplete' }); if ($('shipping:city')) { $('shipping:city').parentNode.appendChild(autocomplete_city_shipping); function updateAddressShipping(text, item) { // Update state and postcode fields var id = item.id; var tokens = id.split('-'); // Assume item at index 1 is region_id, item at index 3 is postcode $('shipping:region_id').value = tokens[1]; $('shipping:postcode').value = tokens[3]; } // Create the autocompleter and assign it to a variable for future use. shipping_completer = new Ajax.Autocompleter("shipping:city", "autocomplete_city_shipping", citySuggestUrl, { afterUpdateElement: updateAddressShipping, minChars: 2, parameters: 'country=' + $F('shipping:country_id') }); } $('shipping:country_id').observe('change', function(event) { shipping_completer.options.defaultParams = 'country=' + $F('shipping:country_id'); }); </script>The text was updated successfully, but these errors were encountered: