I have implemented this snippet to get the address autocomplete to a spesific country. This code works only on an “address” field.
When I use it on a “single line text” field with address autocomplete enabled it wont work. Do you have any suggestions for how I can edit the snippet to make it work on “single line text” field as well?
/**
* Restrict address autocomplete to a specific country
*
* @link https://wpforms.com/developers/how-to-restrict-address-autocomplete-to-a-specific-country/
*/
function wpf_dev_geo_autocomplete_default_country( ) {
?>
<script type="text/javascript">
jQuery(function($){
var formID = 2757; // Change form ID
var addressFieldID = 21; // Change address field ID
// Find field place by country
var stateField = window.WPFormsGeolocationGooglePlacesAPI.findFieldPlaceByPolitical($( #wpforms-${formID}-field_${addressFieldID}-state
)[0]);
// Put a country code here according to this list: https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
// Set default autocomplete country to Canada
stateField.autocomplete.setComponentRestrictions({
'country': [ 'ca' ],
});
});
</script>
<?php
}
add_action( 'wpforms_wp_footer_end', 'wpf_dev_geo_autocomplete_default_country', 30 );
]]>How do I fix this?
https://www.imf.org.au/checkout/
]]>There are are a lot of plugins that offer the address autocomplete on the checkout page. But we creating many orders manually in the backend. We can’t find a plugin that also supports address autocompletion in the backend.
Does anyone has an idea?
We already bought this plugin but it’s only for the frontend:
https://wpovernight.com/downloads/woocommerce-postcode-checker/
Maybe there is a way to activate that plugin for the backend?
Thanks a lot in advance for any reply.
Best regards,
Erjen
Now I want to include UK/US/CN, but would love to still use AddressFinder for AU/NZ addresses. Is there a way to dynamically switch out/in the use of Address Finder depending on the Country/Region dropdown on Checkout billing and shipping addresses?
Happy with a code solution.
Thank you,
Barry
My client wants a form where customers can enter their address, and if it within a certain area, then it shows one message and if not, it shows another.
Anyone have any idea which plugin/combination of plugins might do this??
Thanks in advance!
]]>