Skip to content

Commit a6c6ec5

Browse files
committed
MAGETWO-37928: Cannot remove address on Customer create on Backend
- Fixed formatting due code review.
1 parent 4b4eeea commit a6c6ec5

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,22 @@ define(
5858
return !quote.isVirtual();
5959
},
6060
selectShippingAddress: function() {
61-
var additionalData = {};
62-
var billingAddress = quote.getBillingAddress()();
61+
var additionalFields,
62+
addressData,
63+
additionalData = {},
64+
billingAddress = quote.getBillingAddress()();
65+
6366
if (!billingAddress.customerAddressId || !this.visible()) {
6467
/**
6568
* All the the input fields that are not a part of the address but need to be submitted
6669
* in the same request must have data-scope attribute set
6770
*/
68-
var additionalFields = $('input[data-scope="additionalAddressData"]').serializeArray();
71+
additionalFields = $('input[data-scope="additionalAddressData"]').serializeArray();
6972
additionalFields.forEach(function (field) {
7073
additionalData[field.name] = field.value;
7174
});
7275
}
76+
7377
if (!newAddressSelected()) {
7478
selectShippingAddress(
7579
addressList.getAddressById(this.selectedAddressId()),
@@ -80,23 +84,32 @@ define(
8084
if (this.visible()) {
8185
this.validate();
8286
}
87+
8388
if (!this.source.get('params.invalid')) {
84-
var addressData = this.source.get('shippingAddress');
89+
addressData = this.source.get('shippingAddress');
8590
selectShippingAddress(addressData, this.sameAsBilling(), additionalData);
8691
}
8792
}
8893
},
8994
sameAsBillingClick: function() {
95+
var billingAddress,
96+
shippingAddress,
97+
property;
98+
9099
addressList.isBillingSameAsShipping = !addressList.isBillingSameAsShipping;
100+
91101
if (this.sameAsBilling()) {
92-
var billingAddress = quote.getBillingAddress()();
102+
billingAddress = quote.getBillingAddress()();
103+
93104
if (billingAddress.customerAddressId) {
94105
this.selectedAddressId(billingAddress.customerAddressId);
95106
newAddressSelected(false);
107+
96108
} else {
97109
// copy billing address data to shipping address form if customer uses new address for billing
98-
var shippingAddress = this.source.get('shippingAddress');
99-
for (var property in billingAddress) {
110+
shippingAddress = this.source.get('shippingAddress');
111+
112+
for (property in billingAddress) {
100113
if (billingAddress.hasOwnProperty(property) && shippingAddress.hasOwnProperty(property)) {
101114
if (typeof billingAddress[property] === 'string') {
102115
this.source.set('shippingAddress.' + property, billingAddress[property]);
@@ -105,6 +118,7 @@ define(
105118
}
106119
}
107120
}
121+
108122
this.selectedAddressId(null);
109123
newAddressSelected(true);
110124
}
@@ -113,9 +127,11 @@ define(
113127
},
114128
onAddressChange: function() {
115129
var billingAddress = quote.getBillingAddress();
130+
116131
if (this.selectedAddressId() !== billingAddress().customerAddressId) {
117132
this.sameAsBilling(false);
118133
}
134+
119135
if (this.selectedAddressId() === null) {
120136
newAddressSelected(true);
121137
} else {

0 commit comments

Comments
 (0)