postcode-nl / PostcodeNl_Api_Magento2

A Magento 2 plugin that implements the Postcode.nl international address API
https://developer.postcode.eu/documentation/
BSD 2-Clause "Simplified" License
10 stars 13 forks source link

Autocomplete does not always initialize #46

Closed accentinteractive closed 2 years ago

accentinteractive commented 2 years ago

A client that uses the address autocomplete function had the issue that the autocomplete would not always initialize and only appeared after switching to another country and back.

After checking the logs I saw that an undefined variable causes a KO binding to fail and thus making the autocomplete fail to initialize and also causing cascading errors when trying to change billing addresses in the checkout.

A simple solution was made by overriding the file : view/frontend/web/js/lib/postcode-eu-autocomplete-address.js as line 678

options.context = options.context.toLowerCase();

to

if(options.context){ options.context = options.context.toLowerCase(); }

Kind Regard Rob Theeuwes

JerrySmidt commented 2 years ago

Fixed in version 3.1.5: the KO binding falls back to 'NL' when the country is undefined.