Skip to content

Commit d40d7a2

Browse files
committed
Bug #60304: Fix support for missing shipping form
1 parent 8e6c4d1 commit d40d7a2

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

assets/js/postcode-eu-autofill.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@
472472
const mailLines = getMailLinesNl(values);
473473
storedAddress.set(values, mailLines);
474474

475-
if (addressType === 'billing' && !window.checkout.ship_to_different_address.checked)
475+
if (addressType === 'billing' && isUseBillingAsShipping())
476476
{
477477
// Also set shipping to avoid redundant validation at next pageview.
478478
storedAddresses.shipping.set(values, mailLines);
@@ -655,7 +655,7 @@
655655

656656
storedAddress.set(values, result.mailLines);
657657

658-
if (addressType === 'billing' && !window.checkout.ship_to_different_address.checked)
658+
if (addressType === 'billing' && isUseBillingAsShipping())
659659
{
660660
storedAddresses.shipping.set(values, result.mailLines);
661661
}
@@ -904,18 +904,15 @@
904904
formRow.append(wrapper);
905905
};
906906

907-
// Search PostcodeNlAddressFieldMapping.mapping for given value and
908-
// return the first corresponding key if successful. Otherwise returns null.
909-
const findFieldMapping = (value) => {
910-
for (let key in PostcodeNlAddressFieldMapping.mapping)
907+
const isUseBillingAsShipping = function ()
908+
{
909+
if (typeof window.checkout.ship_to_different_address === 'undefined')
911910
{
912-
if (PostcodeNlAddressFieldMapping.mapping[key] === value)
913-
{
914-
return key;
915-
}
911+
// Return false because there's no shipping form in this case.
912+
return false;
916913
}
917914

918-
return null;
915+
return !window.checkout.ship_to_different_address.checked;
919916
};
920917

921918
class StoredAddress {

0 commit comments

Comments
 (0)