Skip to content

Commit 2bfb4d0

Browse files
committed
@W-21362507: Fix for custom billing address as registered shoppers
Signed-off-by: d.phan <d.phan@salesforce.com>
1 parent add85e3 commit 2bfb4d0

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

packages/template-retail-react-app/app/pages/checkout-one-click/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,10 @@ const CheckoutOneClick = () => {
284284
}
285285

286286
const latestBasketId = currentBasketQuery.data?.basketId || basket.basketId
287+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
288+
const {addressId, creationDate, lastModified, preferred, ...address} = billingAddress
287289
return await updateBillingAddressForBasket({
288-
body: billingAddress,
290+
body: address,
289291
parameters: {basketId: latestBasketId}
290292
})
291293
}

packages/template-retail-react-app/app/pages/checkout-one-click/partials/one-click-contact-info.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,13 @@ const ContactInfo = ({isSocialEnabled = false, idps = [], onRegisteredUserChoseG
483483

484484
// Save phone number to basket billing address for guest shoppers
485485
if (phone) {
486+
const billingBody = {...basket?.billingAddress, phone}
487+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
488+
const {addressId, creationDate, lastModified, preferred, ...address} =
489+
billingBody
486490
await updateBillingAddressForBasket.mutateAsync({
487491
parameters: {basketId: basket.basketId},
488-
body: {
489-
...basket?.billingAddress,
490-
phone: phone
491-
}
492+
body: address
492493
})
493494
}
494495

packages/template-retail-react-app/app/pages/checkout-one-click/partials/one-click-payment.jsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -286,14 +286,11 @@ const Payment = ({
286286
})
287287

288288
if (isPickupOnly && paymentInstrument.billingAddress) {
289-
const addr = {...paymentInstrument.billingAddress}
290-
delete addr.addressId
291-
delete addr.creationDate
292-
delete addr.lastModified
293-
delete addr.preferred
294-
289+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
290+
const {addressId, creationDate, lastModified, preferred, ...address} =
291+
paymentInstrument.billingAddress
295292
await updateBillingAddressForBasket({
296-
body: addr,
293+
body: address,
297294
parameters: {
298295
basketId: activeBasketIdRef.current || basket.basketId
299296
}
@@ -349,13 +346,10 @@ const Payment = ({
349346
)
350347
const addr = saved?.billingAddress
351348
if (addr) {
352-
const cleaned = {...addr}
353-
delete cleaned.addressId
354-
delete cleaned.creationDate
355-
delete cleaned.lastModified
356-
delete cleaned.preferred
349+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
350+
const {addressId, creationDate, lastModified, preferred, ...address} = addr
357351
await updateBillingAddressForBasket({
358-
body: cleaned,
352+
body: address,
359353
parameters: {basketId: activeBasketIdRef.current || basket.basketId}
360354
})
361355
await currentBasketQuery.refetch()

0 commit comments

Comments
 (0)