From 22c60937cd1f08eecc75274ad6bb0fd0acfc866f Mon Sep 17 00:00:00 2001 From: Kevin Meijer Date: Wed, 27 Jul 2022 16:02:41 +0200 Subject: [PATCH] Use address data from form before local storage Use address data from form before using the local storage data. This prevents the fields on your form not showing/hiding when country is changed while other address fields are empty. --- view/frontend/web/js/view/form/postcode.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/view/frontend/web/js/view/form/postcode.js b/view/frontend/web/js/view/form/postcode.js index 88dfea6..7e0ce9c 100644 --- a/view/frontend/web/js/view/form/postcode.js +++ b/view/frontend/web/js/view/form/postcode.js @@ -30,7 +30,9 @@ define([ }, getAddressData: function () { - if (this.addressType == 'shipping' && typeof checkoutData.getShippingAddressFromData() !== 'undefined' && checkoutData.getShippingAddressFromData()) { + if (this.addressType == 'shipping' && this.source && this.source.shippingAddress && this.source.shippingAddress.country_id !== '') { + return this.source.shippingAddress; + } else if (this.addressType == 'shipping' && typeof checkoutData.getShippingAddressFromData() !== 'undefined' && checkoutData.getShippingAddressFromData()) { return checkoutData.getShippingAddressFromData(); } else if (this.addressType == 'billing' && typeof checkoutData.getBillingAddressFromData() !== 'undefined' && checkoutData.getBillingAddressFromData()) { return checkoutData.getBillingAddressFromData();