Skip to content

Commit 52f0507

Browse files
MAGETWO-64544: When logged in customer edits a new shipping address during checkout they are unable to place the order #6488
1 parent a33d8c8 commit 52f0507

File tree

1 file changed

+12
-15
lines changed
  • app/code/Magento/Checkout/view/frontend/web/js/view

1 file changed

+12
-15
lines changed

app/code/Magento/Checkout/view/frontend/web/js/view/shipping.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,15 @@ define([
6060
template: 'Magento_Checkout/shipping',
6161
shippingFormTemplate: 'Magento_Checkout/shipping-address/form',
6262
shippingMethodListTemplate: 'Magento_Checkout/shipping-address/shipping-method-list',
63-
shippingMethodItemTemplate: 'Magento_Checkout/shipping-address/shipping-method-item',
64-
saveInAddressBook: 1,
65-
links: {
66-
saveInAddressBook: '${ $.provider }:shippingAddress.save_in_address_book'
67-
}
63+
shippingMethodItemTemplate: 'Magento_Checkout/shipping-address/shipping-method-item'
6864
},
6965
visible: ko.observable(!quote.isVirtual()),
7066
errorValidationMessage: ko.observable(false),
7167
isCustomerLoggedIn: customer.isLoggedIn,
7268
isFormPopUpVisible: formPopUpState.isVisible,
7369
isFormInline: addressList().length === 0,
7470
isNewAddressAdded: ko.observable(false),
71+
saveInAddressBook: 1,
7572
quoteIsVirtual: quote.isVirtual(),
7673

7774
/**
@@ -117,7 +114,7 @@ define([
117114
if (shippingAddressData) {
118115
checkoutProvider.set(
119116
'shippingAddress',
120-
$.extend({}, checkoutProvider.get('shippingAddress'), shippingAddressData)
117+
$.extend(true, {}, checkoutProvider.get('shippingAddress'), shippingAddressData)
121118
);
122119
}
123120
checkoutProvider.on('shippingAddress', function (shippingAddrsData) {
@@ -129,14 +126,6 @@ define([
129126
return this;
130127
},
131128

132-
/** @inheritdoc */
133-
initObservable: function () {
134-
this._super()
135-
.observe('saveInAddressBook');
136-
137-
return this;
138-
},
139-
140129
/**
141130
* Load data from server for shipping step
142131
*/
@@ -165,6 +154,8 @@ define([
165154

166155
/** @inheritdoc */
167156
click: function () {
157+
// Revert address.
158+
checkoutData.setShippingAddressFromData(self.tempData);
168159
this.closeModal();
169160
}
170161
}
@@ -174,6 +165,12 @@ define([
174165
this.popUpForm.options.closed = function () {
175166
self.isFormPopUpVisible(false);
176167
};
168+
169+
/** @inheritdoc */
170+
this.popUpForm.options.opened = function () {
171+
// Store temporary address for revert action in case when user click cancel action
172+
self.temporaryAddress = $.extend(true, {}, checkoutData.getShippingAddressFromData());
173+
};
177174
popUp = modal(this.popUpForm.options, $(this.popUpForm.element));
178175
}
179176

@@ -200,7 +197,7 @@ define([
200197
if (!this.source.get('params.invalid')) {
201198
addressData = this.source.get('shippingAddress');
202199
// if user clicked the checkbox, its value is true or false. Need to convert.
203-
addressData['save_in_address_book'] = this.saveInAddressBook() ? 1 : 0;
200+
addressData['save_in_address_book'] = this.saveInAddressBook ? 1 : 0;
204201

205202
// New address must be selected as a shipping address
206203
newShippingAddress = createShippingAddress(addressData);

0 commit comments

Comments
 (0)