Skip to content

chore: Handle B2B users scenario #2760

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ export const validateSession = async (
seller: seller?.id,
hasOnlyDefaultSalesChannel: !store?.channel?.value,
}),
b2b: {
customerId: authentication?.customerId?.value ?? '',
},
b2b: authentication?.customerId?.value
? { customerId: authentication.customerId.value }
: null,
marketingData,
person: profile?.id
? {
Expand Down
7 changes: 3 additions & 4 deletions packages/core/src/sdk/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,10 @@ export const mutation = gql(`
export const validateSession = async (session: Session) => {
// If deliveryPromise is enabled and there is no postalCode in the session
if (storeConfig.deliveryPromise?.enabled && !session.postalCode) {
const isLoggedIn = !!session.person?.id
const userId = session.b2b?.customerId ?? session.person?.id

// If user is logged try to get the location (postalCode / geoCoordinates / country) from the user's address
if (isLoggedIn) {
const userId = session.person?.id
// If user is logged in try to get the location (postalCode, geoCoordinates and country) from the user's address
if (userId) {
const address = await getSavedAddress(userId)

// Save the location in the session
Expand Down
Loading