Skip to content

@W-19448788 Tightening the returning shopper flow#3467

Merged
syadupathi-sf merged 6 commits intofeature/1cc_paymentsfrom
syadupathi.W-19448788.fitfinish
Nov 13, 2025
Merged

@W-19448788 Tightening the returning shopper flow#3467
syadupathi-sf merged 6 commits intofeature/1cc_paymentsfrom
syadupathi.W-19448788.fitfinish

Conversation

@syadupathi-sf
Copy link
Collaborator

Description

As a returning user, intermittently, the updateCustomerForBasket call is being made with the guest basket and not the merged basket. The response is a Basket Not Found error. The UI hangs. This is the sequence of events:

  • When are returning shopper goes to the checkout page, a guest basket with an ID is created and is associated with a guest customer with an ID
  • As soon as the shopper authorizes with an OTP, we have a registered customer ID (different than the guest customer ID)
  • Merge basket call is made where the guest basket is merged to a new basket for the registered customer. This basket ID is different than the ID of the guest basket.
  • Now we call updateCustomerForBasket and a basketID is passed to it that comes from the currentbasket query.
  • It seems that intermittently the merge basket is not current yet.

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)

Changes

  • Get the basket ID from the mergeBasket call
  • Use that for the updateCustomerForBasket call

How to Test-Drive This PR

  • Test the returning shopper flow

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)

@syadupathi-sf syadupathi-sf requested a review from a team as a code owner November 12, 2025 18:47
@syadupathi-sf syadupathi-sf added the skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated label Nov 12, 2025
@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Nov 12, 2025

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

Status Scanner Critical High Medium Low Total (0)
Licenses 0 0 0 0 0 issues
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

// Make sure UI reflects merged state before proceeding
await currentBasketQuery.refetch()
const mergedBasketId = merged?.basketId || merged?.basket_id || merged?.id
const refreshedBasketId = await currentBasketQuery.refetch()
Copy link
Contributor

@dannyphan2000 dannyphan2000 Nov 13, 2025

Choose a reason for hiding this comment

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

Do we need to refetch here? Or just using the mergedBasketId is sufficient already for the call below?
From our testing seems like this refetch does not actually give us the right basket currently - or no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The right basket is fetched intermittently. Sometimes it is not. But the situation is that we don't know which is the right basket until we make the updateCustomerForBasket call, which fails when it is not the right basket. Either we completely rely on the mergedBasketId or we have to update the updateCustomerForBasket logic.

body: {email: email}
})
try {
await updateCustomerForBasket.mutateAsync({
Copy link
Contributor

@dannyphan2000 dannyphan2000 Nov 13, 2025

Choose a reason for hiding this comment

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

Would there be a scenario where email is empty here? Prolly not but maybe it's worth doing a check here?
On the other hand, what if we're merged basket already has an email, are we overriding - but then I'm assuming the email would be the same since it's unique per customer?

Choose a reason for hiding this comment

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

Great questions. I would also just add this bit from the API doc.

This endpoint doesn't merge Personally Identifiable Information (PII).

I think it might be technically possible to have a different email because while email will be unique for a login that doesn't necessarily mean that a basket can't contain a different email than the user's login. Pretty edgy scenario but might be technically possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The email cannot be null because we can't move ahead in checkout without entering an email address. And how can the merge basket have a different email address? Aren't we determining the user login based on the email address?

Choose a reason for hiding this comment

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

  1. User logs in to storefront using their email
  2. Creates a basket and edits the email
  3. They leave the storefront without placing an order and subsequently they get logged out
  4. User comes back to storefront as guest and creates a basket
  5. They login via OTP using their users email
  6. We merge baskets. Emails differ

It's an unlikely scenario but I believe it's technically possible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

At step 5, if they are using the changed email, then would they still be associated with the basket created in step 2? We can test this scenario and see what happens.

})
// Make sure UI reflects merged state before proceeding
await currentBasketQuery.refetch()
const mergedBasketId = merged?.basketId || merged?.basket_id || merged?.id

Choose a reason for hiding this comment

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

I dont think the response shape will ever be different in this case will it? If so we need test cases for each otherwise coverage will be affected

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I will remove the ORs

syadupathi-sf and others added 2 commits November 13, 2025 13:19
Signed-off-by: syadupathi-sf <66088780+syadupathi-sf@users.noreply.github.com>
@syadupathi-sf syadupathi-sf merged commit 282db3d into feature/1cc_payments Nov 13, 2025
8 of 11 checks passed
@syadupathi-sf syadupathi-sf deleted the syadupathi.W-19448788.fitfinish branch November 13, 2025 18:20
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.

4 participants