SwissUpLabs Logo

Use Cases

Restrict Results To Specific Country

If you want to show autocomplete results only for specific country, follow the next steps

  • open app/code/Swissup/AddressAutocomplete/view/frontend/web/js/address-autocomplete.js
  • find the following code:

    var autocomplete = new google.maps.places.Autocomplete(el, {
        types: rule.types
    });
    
  • replace it with new code:

    var autocomplete = new google.maps.places.Autocomplete(el, {
        types: rule.types,
        componentRestrictions: {country: "us"}
    });
    
  • find your country code here: Officially assigned code elements

  • save the changes and refresh browser cache.
Edit this Page