Skip to content

chore: handle B2B users scenario - initial location - #2760

Merged
hellofanny merged 21 commits into
mainfrom
chore/b2b-saved-addresses
Jul 2, 2025
Merged

hellofanny merged 21 commits into
mainfrom
chore/b2b-saved-addresses

Conversation

@lucasfp13

@lucasfp13 lucasfp13 commented Apr 2, 2025 •

Copy link
Copy Markdown
Contributor

What's the purpose of this pull request?

Gets user's saved location if logged in (for b2b org scenario)

Unlike b2c approach, where we use the address query, we should try setting the initial location using the postal code from the session (if valid)

How to test it?

Logged In - Saved address Application
image image

note: if the saved postalCode is not valid, the session won't be updated, and you should see a validateSession error in console.

This test account only accepts valid U.S. postal codes.

PS: Need to check with the B2B team if the changes on our side are still needed.

@lucasfp13 lucasfp13 self-assigned this Apr 2, 2025
@lucasfp13
lucasfp13 requested a review from a team as a code owner April 2, 2025 18:03
@lucasfp13
lucasfp13 requested review from hellofanny and renatamottam and removed request for a team April 2, 2025 18:03
@codesandbox-ci

codesandbox-ci Bot commented Apr 2, 2025 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@lariciamota
lariciamota force-pushed the feat/delivery-promise branch from a28d534 to 8fbe4f1 Compare April 8, 2025 12:46
@lucasfp13 lucasfp13 changed the title chore: Handle B2B users chore: Handle B2B users scenario Apr 9, 2025
@hellofanny

Copy link
Copy Markdown
Contributor

@lucasfp13 this PR is blocked for now right? Can we convert to Draft or add a label until we have the other's team reply pls👍

@lariciamota
lariciamota force-pushed the feat/delivery-promise branch from 8805012 to c540749 Compare April 11, 2025 17:59
@lariciamota
lariciamota force-pushed the feat/delivery-promise branch from c540749 to b0aa3d3 Compare April 22, 2025 14:00
@lucasfp13
lucasfp13 marked this pull request as draft April 30, 2025 18:07
@lariciamota
lariciamota force-pushed the feat/delivery-promise branch 2 times, most recently from 789c99a to b41c2a9 Compare May 12, 2025 18:11
Base automatically changed from feat/delivery-promise to main May 13, 2025 12:51
@lucasfp13
lucasfp13 force-pushed the chore/b2b-saved-addresses branch from 87107af to cdb12e7 Compare May 16, 2025 16:51
@hellofanny hellofanny changed the title chore: Handle B2B users scenario chore: handle B2B users scenario - initial location Jun 20, 2025
@hellofanny hellofanny self-assigned this Jun 24, 2025
@hellofanny
hellofanny marked this pull request as ready for review June 24, 2025 01:01

@lucasfp13 lucasfp13 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I can't approve, but LGTM!

Comment thread packages/core/src/sdk/session/index.ts Resolved
lucasfp13 and others added 2 commits June 27, 2025 13:14
This PR intends to ensure all location data (`postalCode`,
`geoCoordinates` and `country`) is being synchronized when needed.

It updates geo coordinates when users set a postal code and ensure
location data won't be overwritten if users grant geo location consent
late.

- Enable Delivery Promise on discovery.config;
- Open the localhost store on anon tab (to ensure no stale data);
- First, consent geo location data from popup and look to the IDB
`fs::session` value, it should fill `geoCoordinates` data after
`useGeolocation` hook execution;
- Then try to set a postal code, the `postalCode` should be set and
`geoCoordinates` should be different now (based on the postal code);
- Another test: open another anon tab and, while the popup asking for
geo location consent set a postal code. Then, after the session is
updated with the new location (based on the postal code), grant the geo
location consent and nothing should happen since user have already set
the postal code.

vtex-sites/starter.store#734

---------

Co-authored-by: Fanny Chien <[email protected]>
Co-authored-by: Larícia Mota <[email protected]>
@hellofanny
hellofanny force-pushed the chore/b2b-saved-addresses branch from 5e7821e to fd74310 Compare June 27, 2025 16:24
@hellofanny
hellofanny force-pushed the chore/b2b-saved-addresses branch from de20be5 to 6180ab0 Compare July 1, 2025 22:38
@hellofanny

Copy link
Copy Markdown
Contributor

Just to clarify, scenarios expected to be covered in this PR:

  1. In case user not logged and no previous postalCode set (from previous session) and default postalCode available in discovery.config. The postalCode will be updated to the default postal code.
  2. In case of B2C logged in and no previous postalCode set, it will try to get the postal code related to the saved address of the user.
image
  1. In case of B2B logged in and no previous postalCode set, it will try to get the postal code related to the saved address of the user available in the session via profile app.

If the postalCode is set by the default postal code from discovery.config it won't change after logged in.
We''ll review the priorities in another PR ✅

@hellofanny
hellofanny merged commit 28ee8b5 into main Jul 2, 2025
@hellofanny
hellofanny deleted the chore/b2b-saved-addresses branch July 2, 2025 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants