Skip to content

Commit

Permalink
Add autocomplete to new address form
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-lisovski committed Jul 8, 2024
1 parent 0f3fbaa commit 61a7396
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions view/frontend/templates/checkout/google-autocomplete-js.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,20 @@ if (!$apiKey) {
// The selectors/field mapping can be found in di.xml, meaning they can be changed without modifying this file.
const fieldMappings = <?= /* @noEscape */ json_encode($fieldMapping->get()) ?>;

const component = Magewire.find(`checkout.${addressType}-details.address-form`);
if (!component) {
console.error(`Cannot find Magewire component checkout.${addressType}-details.address-form`);
return;
}
const form = [
'address-form',
'address-list.form'
];

let component;

form.forEach((form) => {
try {
component = Magewire.find(`checkout.${addressType}-details.` + form);
} catch (e) {
console.debug(`Cannot update Magewire component checkout.${addressType}-details.` + form);
}
});

Object.keys(fieldMappings).forEach(key => {
const value = address[key];
Expand Down

0 comments on commit 61a7396

Please sign in to comment.