Skip to content

@W-18902385 - [BOPIS][Bug] Fix prefilling shipping address bug#2673

Merged
yunakim714 merged 4 commits intofeature/shop-in-storefrom
W-18902385-bug-prefill-address
Jun 27, 2025
Merged

@W-18902385 - [BOPIS][Bug] Fix prefilling shipping address bug#2673
yunakim714 merged 4 commits intofeature/shop-in-storefrom
W-18902385-bug-prefill-address

Conversation

@yunakim714
Copy link
Collaborator

@yunakim714 yunakim714 commented Jun 27, 2025

Description

Previously, if the shopper changed the basket from Pickup in Store -> Delivery then went to the Checkout page, they would see the Shipping Address prefilled because the basket's shippingAddress field had already been filled out. This PR makes sure that the shippingAddress is cleared, and the <ShippingAddress> and <PickupAddress> components now check if the shippingAddress.address1 field has been filled before showing this address to the shopper.

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Clear shippingAddress when changing shipping methods of the basket
  • Check if shippingAddress.address1 value exists:
    • If it does, show the address on the Checkout page
    • If it does not, the shopper should be prompted to fill out the address

How to Test-Drive This PR

  1. Open up Store Locator
  2. Enter 01803 as Zip
  3. Select Burlington Store
  4. Go to Men's, filter by Inventory, add a product to cart with Pickup in Store option
  5. Go to Checkout, verify you see the Pickup Address
  6. Go back to cart, remove the item from cart
  7. Add another product to cart, this time with Delivery option
  8. Go back to Checkout, and the Shipping Address tile should be BLANK

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Jun 27, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Comment on lines +378 to +380
body: {
shippingAddress: {}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't fully clear shippingAddress from the basket shipment. The basket response still contains shippingAddress: { id: 'some-id' }. Does anyone know of any way to fully clear this using the API?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Workaround was to add the isAddressFilled boolean check to both <ShippingAddress> and <PickupAddress> components

Copy link
Contributor

@yhsieh1 yhsieh1 Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yunakim714 I think you can try
/** * Removes a specified shipment and all associated product, gift certificate, shipping, and price adjustment line items from a basket. It is not allowed to remove the default shipment. */ RemoveShipmentFromBasket: 'removeShipmentFromBasket',

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yhsieh1 I saw this API, but unfortunately we are modifying the shipping address of the default shipment, and thus we cannot delete that shipment.

* @param {boolean} hasAnyPickupSelected - Whether any items have pickup selected
* @returns {Promise<void>}
*/
const configureShippingMethodIfNeeded = async (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created a helper function to DRY code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it. is it possible to move this to use-pickup-shipment?

@yunakim714 yunakim714 added the skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated label Jun 27, 2025
@yunakim714 yunakim714 marked this pull request as ready for review June 27, 2025 16:40
@yunakim714 yunakim714 requested a review from a team as a code owner June 27, 2025 16:40
const {data: basket} = useCurrentBasket()

const selectedShippingAddress = basket?.shipments && basket?.shipments[0]?.shippingAddress
const isAddressFilled = selectedShippingAddress?.address1 && selectedShippingAddress?.city
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this i18n safe to assume addresses have a street and city?

* @param {boolean} hasAnyPickupSelected - Whether any items have pickup selected
* @returns {Promise<void>}
*/
const configureShippingMethodIfNeeded = async (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

love it. is it possible to move this to use-pickup-shipment?

* @param {Object} selectedStore - The selected store information
* @returns {Promise<void>}
*/
const configureShippingMethodIfNeeded = async (
Copy link
Collaborator Author

@yunakim714 yunakim714 Jun 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved this helper into the usePickupShipment hook so we can keep pickup logic outside of the PDP page

Copy link
Contributor

@patricksullivansf patricksullivansf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

beautiful. thank you

@yunakim714 yunakim714 merged commit 3ea409c into feature/shop-in-store Jun 27, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants