From d82f3ea67a9e5a37aed5b87addb7e929acf7b94e Mon Sep 17 00:00:00 2001 From: Ilia Rachkulik Date: Wed, 3 May 2017 14:21:02 +0530 Subject: [PATCH 1/2] magento/magento2#7497 - Shipping method radios become disabled when checkout page refreshed - Backport fix MAGETWO-56073 --- .../frontend/web/js/model/new-customer-address.js | 11 +++++++++-- .../Checkout/view/frontend/web/js/view/shipping.js | 2 +- .../view/frontend/web/js/model/customer/address.js | 8 +++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js b/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js index 40875ceba3571..8146c957c4ab7 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js @@ -10,7 +10,14 @@ define([], function () { * Returns new address object */ return function (addressData) { - var identifier = Date.now(); + var identifier = Date.now(), + regionId; + + if (addressData.region && addressData.region.region_id) { + regionId = addressData.region.region_id; + } else if (addressData.country_id && addressData.country_id == window.checkoutConfig.defaultCountryId) { + regionId = window.checkoutConfig.defaultRegionId || undefined; + } return { email: addressData.email, @@ -20,7 +27,7 @@ define([], function () { : window.checkoutConfig.defaultRegionId, regionCode: (addressData.region) ? addressData.region.region_code : null, region: (addressData.region) ? addressData.region.region : null, - customerId: addressData.customer_id, + customerId: addressData.customer_id || addressData.customerId, street: addressData.street, company: addressData.company, telephone: addressData.telephone, diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js index d9950ae2cc7ef..5c082e6a89df1 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js @@ -79,7 +79,6 @@ define( fieldsetName = 'checkout.steps.shipping-step.shippingAddress.shipping-address-fieldset'; this._super(); - shippingRatesValidator.initFields(fieldsetName); if (!quote.isVirtual()) { stepNavigator.registerStep( @@ -120,6 +119,7 @@ define( checkoutProvider.on('shippingAddress', function (shippingAddressData) { checkoutData.setShippingAddressFromData(shippingAddressData); }); + shippingRatesValidator.initFields(fieldsetName); }); return this; diff --git a/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js b/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js index 07a223528e3c1..601fd09a056c4 100644 --- a/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js +++ b/app/code/Magento/Customer/view/frontend/web/js/model/customer/address.js @@ -10,11 +10,17 @@ define([], function() { * Returns new address object */ return function (addressData) { + var regionId; + + if (addressData.region['region_id'] && addressData.region['region_id'] !== '0') { + regionId = addressData.region['region_id'] + ''; + } + return { customerAddressId: addressData.id, email: addressData.email, countryId: addressData.country_id, - regionId: addressData.region_id, + regionId: regionId, regionCode: addressData.region.region_code, region: addressData.region.region, customerId: addressData.customer_id, From 8c33f6838ed667ec9def07e7984f483605cde89e Mon Sep 17 00:00:00 2001 From: Ilia Rachkulik Date: Wed, 3 May 2017 14:49:14 +0530 Subject: [PATCH 2/2] magento/magento2#7497 - Shipping method radios become disabled when checkout page refreshed - Fixed based on request --- .../view/frontend/web/js/model/new-customer-address.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js b/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js index 8146c957c4ab7..a8f4c8fb14491 100644 --- a/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js +++ b/app/code/Magento/Checkout/view/frontend/web/js/model/new-customer-address.js @@ -22,9 +22,7 @@ define([], function () { return { email: addressData.email, countryId: addressData['country_id'] || addressData.countryId || window.checkoutConfig.defaultCountryId, - regionId: (addressData.region && addressData.region.region_id) ? - addressData.region.region_id - : window.checkoutConfig.defaultRegionId, + regionId: regionId || addressData.regionId, regionCode: (addressData.region) ? addressData.region.region_code : null, region: (addressData.region) ? addressData.region.region : null, customerId: addressData.customer_id || addressData.customerId,