From 771d9a10f41b039aa13b7985fd2fa82ccf389747 Mon Sep 17 00:00:00 2001 From: tkostuch Date: Tue, 17 Dec 2019 14:52:02 +0100 Subject: [PATCH 1/3] fix for update address in my shipping details --- .../modules/user/components/UserShippingDetails.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/core/modules/user/components/UserShippingDetails.ts b/core/modules/user/components/UserShippingDetails.ts index bba3b74a4e..fee575f651 100644 --- a/core/modules/user/components/UserShippingDetails.ts +++ b/core/modules/user/components/UserShippingDetails.ts @@ -93,14 +93,14 @@ export const UserShippingDetails = { default_shipping: true } if (this.currentUser.hasOwnProperty('default_shipping')) { - let i - for (i = 0; i < this.currentUser.addresses.length; i++) { - if (toString(this.currentUser.addresses[i].id) === toString(this.currentUser.default_shipping)) { - updatedShippingDetails.addresses[i] = updatedShippingDetailsAddress; - } - } - if (this.currentUser.addresses.length === 0 || i === this.currentUser.addresses.length) { + if (this.currentUser.addresses.length === 0) { updatedShippingDetails = null + } else { + for (let i = 0; i < this.currentUser.addresses.length; i++) { + if (toString(this.currentUser.addresses[i].id) === toString(this.currentUser.default_shipping)) { + updatedShippingDetails.addresses[i] = updatedShippingDetailsAddress; + } + } } } else { updatedShippingDetails.addresses.push(updatedShippingDetailsAddress) From 4c9d2432bff54bcbb1f8c495e9b9e6209aabb4fc Mon Sep 17 00:00:00 2001 From: tkostuch Date: Tue, 17 Dec 2019 15:34:54 +0100 Subject: [PATCH 2/3] add default_shipping flag only when creates new address --- .../user/components/UserShippingDetails.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/core/modules/user/components/UserShippingDetails.ts b/core/modules/user/components/UserShippingDetails.ts index fee575f651..d9aacfc805 100644 --- a/core/modules/user/components/UserShippingDetails.ts +++ b/core/modules/user/components/UserShippingDetails.ts @@ -89,21 +89,24 @@ export const UserShippingDetails = { ...(this.shippingDetails.region ? { region: { region: this.shippingDetails.region } } : {}), country_id: this.shippingDetails.country, postcode: this.shippingDetails.postcode, - ...(this.shippingDetails.phone ? { telephone: this.shippingDetails.phone } : {}), - default_shipping: true + ...(this.shippingDetails.phone ? { telephone: this.shippingDetails.phone } : {}) } if (this.currentUser.hasOwnProperty('default_shipping')) { if (this.currentUser.addresses.length === 0) { updatedShippingDetails = null } else { - for (let i = 0; i < this.currentUser.addresses.length; i++) { - if (toString(this.currentUser.addresses[i].id) === toString(this.currentUser.default_shipping)) { - updatedShippingDetails.addresses[i] = updatedShippingDetailsAddress; - } - } + updatedShippingDetails.addresses = updatedShippingDetails.addresses.map((address) => + toString(address.id) === toString(this.currentUser.default_shipping) + ? {...address, ...updatedShippingDetailsAddress} // update default address if already exist + : address + ) } } else { - updatedShippingDetails.addresses.push(updatedShippingDetailsAddress) + // create default address + updatedShippingDetails.addresses.push({ + ...updatedShippingDetailsAddress, + default_shipping: true + }) } } this.exitSection(null, updatedShippingDetails) From cefe02be79bb33cf86d7e3e346524dac3cd91ab3 Mon Sep 17 00:00:00 2001 From: tkostuch Date: Tue, 17 Dec 2019 15:39:41 +0100 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 718c6f4d03..a7e1537ccc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed Breadcrumb filters - apply to second category fetch - @grimasod (#3887) - Fixed `config.storeViews.commonCache` being ignored - @grimasod (#3895) - Fixed static pages, password notification, offline mode #3902 - @andrzejewsky (#3902) +- Fixed edit shipping address in my account - @gibkigonzo (#3921) ### Changed / Improved - Changed pre commit hook to use NODE_ENV production to check for debugger statements - @resubaka (#3686)