@zonos/elements 1.3.258 → 1.3.259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/zonos-checkout.cjs.entry.js +439 -14
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +6 -6
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +72 -0
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +6 -6
- package/dist/collection/components/utils/checkout/bigcommerceStorefrontApi.js +6 -0
- package/dist/collection/components/utils/checkout/buildBigcommerceLoginUrl.js +65 -0
- package/dist/collection/components/utils/checkout/checkBigCommerceBypassCustomerGroup.js +12 -7
- package/dist/collection/components/utils/checkout/checkBigCommerceForceLogin.js +116 -0
- package/dist/collection/components/utils/checkout/fetchBigCommerceCheckoutSettings.js +92 -0
- package/dist/collection/components/utils/checkout/fixBigCommerceLoginCreateAccountLink.js +53 -0
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +40 -7
- package/dist/collection/types/checkout/api/BigCommerceCheckoutSettings.js +1 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +2 -0
- package/dist/collection/types/generated/graphql.internal.types.js +39 -0
- package/dist/collection/types/index.js +1 -0
- package/dist/esm/index.js +7 -7
- package/dist/esm/zonos-checkout.entry.js +440 -15
- package/dist/esm/zonos-hello-dialog.entry.js +6 -6
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/scripts/index.d.ts +21 -5
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +16 -0
- package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
- package/dist/types/components/utils/checkout/bigcommerceStorefrontApi.d.ts +6 -0
- package/dist/types/components/utils/checkout/buildBigcommerceLoginUrl.d.ts +27 -0
- package/dist/types/components/utils/checkout/checkBigCommerceBypassCustomerGroup.d.ts +12 -0
- package/dist/types/components/utils/checkout/checkBigCommerceForceLogin.d.ts +50 -0
- package/dist/types/components/utils/checkout/fetchBigCommerceCheckoutSettings.d.ts +18 -0
- package/dist/types/components/utils/checkout/fixBigCommerceLoginCreateAccountLink.d.ts +17 -0
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +6 -5
- package/dist/types/types/checkout/CheckoutConfig.d.ts +9 -0
- package/dist/types/types/checkout/api/BigCommerceCheckoutSettings.d.ts +12 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +3 -1
- package/dist/types/types/generated/graphql.frontend.types.ts +3 -1
- package/dist/types/types/generated/graphql.internal.types.d.ts +58 -9
- package/dist/types/types/generated/graphql.internal.types.ts +69 -9
- package/dist/types/types/index.d.ts +1 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/p-439dc620.system.entry.js +1 -0
- package/dist/zonos-elements/{p-5182e492.entry.js → p-9cbac993.entry.js} +1 -1
- package/dist/zonos-elements/{p-867d05d7.system.js → p-cc645667.system.js} +1 -1
- package/dist/zonos-elements/p-d13120f6.entry.js +1 -0
- package/dist/zonos-elements/{p-9c97671b.system.entry.js → p-f4e54f09.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-50b32476.system.entry.js +0 -1
- package/dist/zonos-elements/p-733f118d.entry.js +0 -1
|
@@ -13,8 +13,11 @@ import { selectVarianceTest } from "../../utils/api/selectVarianceTest";
|
|
|
13
13
|
import { trackConversionEvent } from "../../utils/api/trackConversionEvent";
|
|
14
14
|
import { updateCheckoutSessionAttributes } from "../../utils/api/updateCheckoutSessionAttributes";
|
|
15
15
|
import { buildCartUrl } from "../../utils/buildCartUrl";
|
|
16
|
+
import { BIGCOMMERCE_INTERNATIONAL_CHECKOUT_FLAG } from "../../utils/checkout/buildBigcommerceLoginUrl";
|
|
16
17
|
import { buildBigcommerceRedirectUrl } from "../../utils/checkout/buildBigcommerceRedirectUrl";
|
|
17
18
|
import { checkBigCommerceBypassCustomerGroup, initBigCommerceBypassCheck, } from "../../utils/checkout/checkBigCommerceBypassCustomerGroup";
|
|
19
|
+
import { checkBigCommerceForceLogin, initBigCommerceForceLoginCheck, } from "../../utils/checkout/checkBigCommerceForceLogin";
|
|
20
|
+
import { fixBigCommerceLoginCreateAccountLink } from "../../utils/checkout/fixBigCommerceLoginCreateAccountLink";
|
|
18
21
|
import { getAbandonedCartRenewTokenValue } from "../../utils/checkout/getAbandonedCartRenewTokenValue";
|
|
19
22
|
import { getIsStagingMode } from "../../utils/checkout/getIsStagingMode";
|
|
20
23
|
import { getIsTestMode } from "../../utils/checkout/getIsTestMode";
|
|
@@ -790,6 +793,15 @@ export class ZonosCheckout {
|
|
|
790
793
|
window.location.href = buildBigcommerceRedirectUrl('/checkout');
|
|
791
794
|
return;
|
|
792
795
|
}
|
|
796
|
+
// Merchants who disable BC guest checkout need the shopper
|
|
797
|
+
// signed in before we open the Zonos international checkout.
|
|
798
|
+
// Redirecting here keeps the dialog from flashing before the
|
|
799
|
+
// login bounce.
|
|
800
|
+
const forceLogin = await checkBigCommerceForceLogin();
|
|
801
|
+
if (forceLogin.shouldForceLogin && forceLogin.redirectUrl) {
|
|
802
|
+
window.location.href = forceLogin.redirectUrl;
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
793
805
|
}
|
|
794
806
|
// start loading
|
|
795
807
|
stripeStore.isFetchingSession = true;
|
|
@@ -1042,6 +1054,19 @@ export class ZonosCheckout {
|
|
|
1042
1054
|
// Start fetching BigCommerce customer group on page load so the bypass
|
|
1043
1055
|
// result is ready by the time checkout opens or the BC watcher fires
|
|
1044
1056
|
initBigCommerceBypassCheck();
|
|
1057
|
+
// Warm the BigCommerce `/checkouts/settings` fetch (merchant's
|
|
1058
|
+
// `guest_checkout_type`) so force-login gating resolves instantly when
|
|
1059
|
+
// the shopper clicks checkout — otherwise the first checkout open
|
|
1060
|
+
// would block on a proxy round trip.
|
|
1061
|
+
initBigCommerceForceLoginCheck();
|
|
1062
|
+
// On BC's `/login.php`, rewrite the "Create account" button href so
|
|
1063
|
+
// the post-signup round trip preserves the `from=cart.php?...` flag
|
|
1064
|
+
// that carries the shopper back into Zonos international checkout.
|
|
1065
|
+
fixBigCommerceLoginCreateAccountLink();
|
|
1066
|
+
// If BC redirected the shopper back here after login with the Zonos
|
|
1067
|
+
// resume flag, auto-open the international checkout. Strip the flag
|
|
1068
|
+
// from the URL so a refresh doesn't keep re-triggering the dialog.
|
|
1069
|
+
this.handleBigcommerceInternationalResumeFlag();
|
|
1045
1070
|
// check if bigcommerce, if user enters the shipping address that's in the shipping zone at bigcommerce checkout
|
|
1046
1071
|
watchImmediateBigcommerceDomesticCheckoutRedirect({
|
|
1047
1072
|
domesticRedirectedBtnSelector: domesticRedirectedBtnSelector,
|
|
@@ -1123,6 +1148,53 @@ export class ZonosCheckout {
|
|
|
1123
1148
|
clearInterval(interval);
|
|
1124
1149
|
}, 10000);
|
|
1125
1150
|
}
|
|
1151
|
+
/**
|
|
1152
|
+
* After BigCommerce's `/login.php` round trip, the shopper lands back on
|
|
1153
|
+
* `cart.php?isInternationalCheckout=true`. Detect the flag, strip it from
|
|
1154
|
+
* the URL (so refreshing doesn't re-open the dialog), then fire the
|
|
1155
|
+
* international-checkout trigger once three preconditions are all met:
|
|
1156
|
+
* 1. Hello localization finished loading (`localizationLoaded`).
|
|
1157
|
+
* 2. A country code is selected — otherwise `buildCartDetail` runs
|
|
1158
|
+
* without a `countryCode` / `currencyCode` and never builds a cart.
|
|
1159
|
+
* 3. The hidden trigger button has mounted.
|
|
1160
|
+
*
|
|
1161
|
+
* Without the first two gates we race Hello's own init and the click
|
|
1162
|
+
* fires against a half-initialized store, which is what happens when
|
|
1163
|
+
* the shopper refreshes back into cart.php straight from the login
|
|
1164
|
+
* round trip.
|
|
1165
|
+
*/
|
|
1166
|
+
handleBigcommerceInternationalResumeFlag() {
|
|
1167
|
+
if (!window.Zonos.isBigCommerce) {
|
|
1168
|
+
return;
|
|
1169
|
+
}
|
|
1170
|
+
const url = new URL(window.location.href);
|
|
1171
|
+
if (url.searchParams.get(BIGCOMMERCE_INTERNATIONAL_CHECKOUT_FLAG) !== 'true') {
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1174
|
+
url.searchParams.delete(BIGCOMMERCE_INTERNATIONAL_CHECKOUT_FLAG);
|
|
1175
|
+
window.history.replaceState({}, '', url.toString());
|
|
1176
|
+
const start = Date.now();
|
|
1177
|
+
const interval = setInterval(() => {
|
|
1178
|
+
if (!localizationStore.localizationLoaded ||
|
|
1179
|
+
!localizationStore.selectedCountryCode) {
|
|
1180
|
+
if (Date.now() - start > 15000) {
|
|
1181
|
+
clearInterval(interval);
|
|
1182
|
+
log('BigCommerce international checkout resume flag: localization did not initialize within 15s', 'info');
|
|
1183
|
+
}
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
const btn = document.querySelector(`#${checkoutHiddenInternationalBtnSelector}`);
|
|
1187
|
+
if (btn) {
|
|
1188
|
+
clearInterval(interval);
|
|
1189
|
+
btn.dispatchEvent(createCustomEvent('click'));
|
|
1190
|
+
return;
|
|
1191
|
+
}
|
|
1192
|
+
if (Date.now() - start > 15000) {
|
|
1193
|
+
clearInterval(interval);
|
|
1194
|
+
log('BigCommerce international checkout resume flag: trigger button did not mount within 15s', 'info');
|
|
1195
|
+
}
|
|
1196
|
+
}, 200);
|
|
1197
|
+
}
|
|
1126
1198
|
/**
|
|
1127
1199
|
* For storybook to set to finish step, this is to trigger in the story for zonos-checkout-finish
|
|
1128
1200
|
*/
|
|
@@ -105,7 +105,7 @@ export class ZonosHelloDialog {
|
|
|
105
105
|
};
|
|
106
106
|
this.getDutyMessage = () => {
|
|
107
107
|
// Domestic orders stay within the merchant's origin country, so no
|
|
108
|
-
// duty is ever assessed —
|
|
108
|
+
// duty is ever assessed — skip the de minimis message.
|
|
109
109
|
if (this.isDomesticCountry()) {
|
|
110
110
|
return null;
|
|
111
111
|
}
|
|
@@ -129,7 +129,7 @@ export class ZonosHelloDialog {
|
|
|
129
129
|
this.getTaxMessage = () => {
|
|
130
130
|
const { countryLandedCost } = localizationStore;
|
|
131
131
|
// Domestic orders stay within the merchant's origin country, so no
|
|
132
|
-
//
|
|
132
|
+
// import tax is ever assessed — skip the de minimis message.
|
|
133
133
|
if (this.isDomesticCountry()) {
|
|
134
134
|
return null;
|
|
135
135
|
}
|
|
@@ -345,25 +345,25 @@ export class ZonosHelloDialog {
|
|
|
345
345
|
// If deminimis is undefined or null, assume it's $0
|
|
346
346
|
const taxDeMinimisMessage = this.getTaxMessage();
|
|
347
347
|
const inclusivePriceMessage = this.getInclusivePriceMessage();
|
|
348
|
-
return (h(Host, { key: '
|
|
348
|
+
return (h(Host, { key: '910b2b5600107a097fa4cdc77ec487e03fe6a8d2', class: "zonos--elements" }, h("div", { key: 'edf1d9b554807db1c973a1ccdb6e20a647c24204', class: classes([
|
|
349
349
|
'zonos--hello-dialog',
|
|
350
350
|
animateLeft && 'zonos--hello-dialog-animate-from-left',
|
|
351
351
|
animateFromBottom && 'zonos--hello-dialog-animate-from-bottom',
|
|
352
352
|
!!this.mobileLocationOverride &&
|
|
353
353
|
'zonos--hello-dialog-mobile-override',
|
|
354
354
|
this.isOpen && 'zonos--hello-dialog-open',
|
|
355
|
-
]), inert: !this.isOpen, ref: el => el && (this.dialogRef = el) }, !this.showCountrySelect && !this.showLanguageSelect && (h("div", { key: '
|
|
355
|
+
]), inert: !this.isOpen, ref: el => el && (this.dialogRef = el) }, !this.showCountrySelect && !this.showLanguageSelect && (h("div", { key: 'f5316102d12d07e1a3c701ad641995413ee445b2' }, h("div", { key: 'c11cc7e8d11f733c82435a531d7d8595b0237eae', class: "zonos--hello-dialog-content" }, h("zonos-button", { key: 'a2aa2802331e9ed5c40d877fcb7ffb0cebd318c5', class: "zonos--close-button", icon: h("zonos-icon", { "aria-label": "Close Zonos Hello dialog", content: RemoveIcon }), noBackground: true, onClick: () => this.setIsOpen(false) }), h("zonos-v-stack", { key: 'f6df6e6562b8ddebb0e910d669a6a263114f6407', spacing: 24 }, h("zonos-country-flag", { key: '71c320b3364deee7c545284a2fc639cef3a3ba27', class: "zonos--hello-country-flag", countryCode: selectedCountryCode }), h("zonos-v-stack", { key: '9603247163d334db33fe00428190fafdd6ef6c42', class: "zonos--hello-dialog-header", spacing: 4 }, h("zonos-text", { key: 'aad7fd909092a9fad15ce88a3f43ad5115bca1f9', type: "boldSubheader" }, welcomeMessage), h("zonos-text", { key: 'c3c9c5d5f9e1000b2b6c6aebc73f18c6653f9de2', innerHTML: defaultMessage, textColor: "gray-800" })), h("zonos-v-stack", { key: 'c34b1b9debb507ce6f230bd13b493a14af12e880', spacing: 8 }, this.restrictedItems.map(item => {
|
|
356
356
|
var _a;
|
|
357
357
|
return item && (h("zonos-banner", { bannerTitle: item.name, intent: "error" }, (_a = item.itemRestrictions) === null || _a === void 0 ? void 0 : _a.map(x => (h("zonos-text", { textColor: "red-800" }, x === null || x === void 0 ? void 0 : x.note)))));
|
|
358
358
|
}), (dutyDeMinimisMessage ||
|
|
359
359
|
taxDeMinimisMessage ||
|
|
360
360
|
inclusivePriceMessage ||
|
|
361
|
-
!!(additionalInformation === null || additionalInformation === void 0 ? void 0 : additionalInformation.length)) && (h("zonos-card", { key: '
|
|
361
|
+
!!(additionalInformation === null || additionalInformation === void 0 ? void 0 : additionalInformation.length)) && (h("zonos-card", { key: '5dc5af9af7263333433b8a0382a30ccf9f28056d', spacing: "12px" }, h("zonos-v-stack", { key: '725669eaca664abc90f5ec8181c3b81c05cc3b52', spacing: 12 }, this.renderHelloMessage({
|
|
362
362
|
dutyDeMinimisMessage,
|
|
363
363
|
inclusivePriceMessage,
|
|
364
364
|
taxDeMinimisMessage,
|
|
365
365
|
}), additionalInformation === null || additionalInformation === void 0 ? void 0 :
|
|
366
|
-
additionalInformation.map(info => (h("div", { class: "zonos--flex-message" }, h("zonos-icon", { "aria-label": "Additional information for buying goods from selected country icon", content: BagIcon }), h("zonos-text", { "aria-label": `Additional information for buying goods from selected country message`, innerHTML: info }))))))), filteredMessages.map(x => (h("zonos-custom-message", { icon: MessageIcon, message: x.message })))))), h("zonos-hello-dialog-footer", { key: '
|
|
366
|
+
additionalInformation.map(info => (h("div", { class: "zonos--flex-message" }, h("zonos-icon", { "aria-label": "Additional information for buying goods from selected country icon", content: BagIcon }), h("zonos-text", { "aria-label": `Additional information for buying goods from selected country message`, innerHTML: info }))))))), filteredMessages.map(x => (h("zonos-custom-message", { icon: MessageIcon, message: x.message })))))), h("zonos-hello-dialog-footer", { key: '077adfd58b2d7d95d5f352a09783089a1e91c99f', appearanceSettings: this.appearanceSettings, setShowCountrySelect: value => this.setShowCountrySelect(value), setShowLanguageSelect: value => this.setShowLanguageSelect(value) }))), this.showCountrySelect && (h("div", { key: '8c2dd5d73a649eebf1517a9b359d3ecc93b12620' }, h("zonos-country-select", { key: 'e2f64c73efe1e931808fdfe6aa5f8545d6f39c93', handleOnClose: () => this.setShowCountrySelect(false) }))), this.showLanguageSelect && (h("div", { key: '0b9ba684ac67fa652a34e6fbad8e966970f391ce' }, h("zonos-language-select", { key: '2e03e02459b0f31bc69376bc154ed8bb2d96ef56', handleOnClose: () => this.setShowLanguageSelect(false) }))))));
|
|
367
367
|
}
|
|
368
368
|
static get is() { return "zonos-hello-dialog"; }
|
|
369
369
|
static get encapsulation() { return "shadow"; }
|
|
@@ -50,3 +50,9 @@ export const fetchBigCommerceCheckout = async (checkoutId) => {
|
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
+
/**
|
|
54
|
+
* Whether the BigCommerce shopper is already logged in. We key off the
|
|
55
|
+
* customer's numeric `id` since the storefront API populates it only for
|
|
56
|
+
* authenticated sessions (guest checkouts have an empty `customer` object).
|
|
57
|
+
*/
|
|
58
|
+
export const isBigCommerceCustomerLoggedIn = (checkout) => { var _a; return !!((_a = checkout === null || checkout === void 0 ? void 0 : checkout.customer) === null || _a === void 0 ? void 0 : _a.id); };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { getIsTestMode } from "./getIsTestMode";
|
|
2
|
+
/**
|
|
3
|
+
* The query flag that BigCommerce carries back to `cart.php` after the
|
|
4
|
+
* shopper logs in. When present, Zonos-elements knows to resume the
|
|
5
|
+
* international checkout flow instead of letting BC's native cart UX
|
|
6
|
+
* take over.
|
|
7
|
+
*/
|
|
8
|
+
export const BIGCOMMERCE_INTERNATIONAL_CHECKOUT_FLAG = 'isInternationalCheckout';
|
|
9
|
+
/**
|
|
10
|
+
* Build the `from` query value handed to BigCommerce's `/login.php` so that
|
|
11
|
+
* after a successful login the shopper lands back on `cart.php` with the
|
|
12
|
+
* `isInternationalCheckout=true` flag set (plus any `zonosTestMode` /
|
|
13
|
+
* `zonosQaUrl` / `zonosQaUrlApi` that were on the current URL, so the
|
|
14
|
+
* preview build / API host / test credentials carry through the round trip).
|
|
15
|
+
*/
|
|
16
|
+
const buildFromCartPath = () => {
|
|
17
|
+
const params = new URLSearchParams();
|
|
18
|
+
params.set(BIGCOMMERCE_INTERNATIONAL_CHECKOUT_FLAG, 'true');
|
|
19
|
+
const currentParams = new URLSearchParams(window.location.search);
|
|
20
|
+
const zonosQaUrl = currentParams.get('zonosQaUrl');
|
|
21
|
+
if (zonosQaUrl) {
|
|
22
|
+
params.set('zonosQaUrl', zonosQaUrl);
|
|
23
|
+
}
|
|
24
|
+
const zonosQaUrlApi = currentParams.get('zonosQaUrlApi');
|
|
25
|
+
if (zonosQaUrlApi) {
|
|
26
|
+
params.set('zonosQaUrlApi', zonosQaUrlApi);
|
|
27
|
+
}
|
|
28
|
+
if (getIsTestMode()) {
|
|
29
|
+
params.set('zonosTestMode', '1');
|
|
30
|
+
}
|
|
31
|
+
return `cart.php?${params.toString()}`;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Build an absolute URL to BigCommerce's `/login.php` with the
|
|
35
|
+
* `from=cart.php?isInternationalCheckout=true` round-trip encoded so the
|
|
36
|
+
* shopper resumes Zonos international checkout after authenticating.
|
|
37
|
+
*
|
|
38
|
+
* Preserves `zonosTestMode` / `zonosQaUrl` / `zonosQaUrlApi` from the current
|
|
39
|
+
* URL across the redirect — the login round trip leaves BC's frontend, so
|
|
40
|
+
* without this the returning `cart.php` would drop back to the production
|
|
41
|
+
* build / API host.
|
|
42
|
+
*/
|
|
43
|
+
export const buildBigcommerceLoginUrl = ({ action } = {}) => {
|
|
44
|
+
const url = new URL('/login.php', window.location.origin);
|
|
45
|
+
if (action) {
|
|
46
|
+
url.searchParams.set('action', action);
|
|
47
|
+
}
|
|
48
|
+
const currentParams = new URLSearchParams(window.location.search);
|
|
49
|
+
// set zonosQaUrl from the current URL
|
|
50
|
+
const zonosQaUrl = currentParams.get('zonosQaUrl');
|
|
51
|
+
if (zonosQaUrl) {
|
|
52
|
+
url.searchParams.set('zonosQaUrl', zonosQaUrl);
|
|
53
|
+
}
|
|
54
|
+
// set zonosQaUrlApi from the current URL
|
|
55
|
+
const zonosQaUrlApi = currentParams.get('zonosQaUrlApi');
|
|
56
|
+
if (zonosQaUrlApi) {
|
|
57
|
+
url.searchParams.set('zonosQaUrlApi', zonosQaUrlApi);
|
|
58
|
+
}
|
|
59
|
+
// set zonosTestMode from the current URL
|
|
60
|
+
if (getIsTestMode()) {
|
|
61
|
+
url.searchParams.set('zonosTestMode', '1');
|
|
62
|
+
}
|
|
63
|
+
url.searchParams.set('from', buildFromCartPath());
|
|
64
|
+
return url.toString();
|
|
65
|
+
};
|
|
@@ -9,7 +9,7 @@ const DEFAULT_RESULT = {
|
|
|
9
9
|
* Performs the actual fetch logic to determine if the customer
|
|
10
10
|
* belongs to a bypass group.
|
|
11
11
|
*/
|
|
12
|
-
const fetchBypassOutcome = async () => {
|
|
12
|
+
const fetchBypassOutcome = async (preFetched) => {
|
|
13
13
|
var _a, _b, _c, _d;
|
|
14
14
|
// Only relevant for BigCommerce stores — permanent no-op on other platforms
|
|
15
15
|
if (!window.Zonos.isBigCommerce) {
|
|
@@ -26,8 +26,11 @@ const fetchBypassOutcome = async () => {
|
|
|
26
26
|
// Mark as inconclusive so a later caller retries after config loads.
|
|
27
27
|
return { conclusive: false, result: DEFAULT_RESULT };
|
|
28
28
|
}
|
|
29
|
-
// Fetch customer group from BigCommerce Storefront API
|
|
30
|
-
|
|
29
|
+
// Fetch customer group from BigCommerce Storefront API — or reuse
|
|
30
|
+
// caller-supplied data when available.
|
|
31
|
+
const checkoutId = preFetched
|
|
32
|
+
? preFetched.checkoutId
|
|
33
|
+
: await fetchCheckoutId();
|
|
31
34
|
if (!checkoutId) {
|
|
32
35
|
// No active cart yet — inconclusive. Common on fresh sessions where
|
|
33
36
|
// `initBigCommerceBypassCheck` runs before the user has added anything
|
|
@@ -35,7 +38,9 @@ const fetchBypassOutcome = async () => {
|
|
|
35
38
|
log('BigCommerce bypass check: no active cart yet, will retry on next call', 'info');
|
|
36
39
|
return { conclusive: false, result: DEFAULT_RESULT };
|
|
37
40
|
}
|
|
38
|
-
const checkout =
|
|
41
|
+
const checkout = preFetched
|
|
42
|
+
? preFetched.checkout
|
|
43
|
+
: await fetchBigCommerceCheckout(checkoutId);
|
|
39
44
|
if (!checkout) {
|
|
40
45
|
// API call failed (network error, non-200, etc.) — inconclusive.
|
|
41
46
|
// Caching this would permanently disable bypass for the session if
|
|
@@ -69,8 +74,8 @@ const fetchBypassOutcome = async () => {
|
|
|
69
74
|
* cart or after settings finish loading).
|
|
70
75
|
*/
|
|
71
76
|
let bypassCheckPromise = null;
|
|
72
|
-
const startBypassCheck = () => {
|
|
73
|
-
const outcomePromise = fetchBypassOutcome();
|
|
77
|
+
const startBypassCheck = (preFetched) => {
|
|
78
|
+
const outcomePromise = fetchBypassOutcome(preFetched);
|
|
74
79
|
const resultPromise = outcomePromise.then(({ conclusive, result }) => {
|
|
75
80
|
if (!conclusive && bypassCheckPromise === resultPromise) {
|
|
76
81
|
// Invalidate cache so the next caller performs a fresh fetch.
|
|
@@ -116,7 +121,7 @@ export const initBigCommerceBypassCheck = () => {
|
|
|
116
121
|
*/
|
|
117
122
|
export const checkBigCommerceBypassCustomerGroup = async (options = {}) => {
|
|
118
123
|
if (options.forceRefresh || !bypassCheckPromise) {
|
|
119
|
-
return startBypassCheck();
|
|
124
|
+
return startBypassCheck(options.preFetched);
|
|
120
125
|
}
|
|
121
126
|
return bypassCheckPromise;
|
|
122
127
|
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { fetchBigCommerceCheckout, fetchCheckoutId, isBigCommerceCustomerLoggedIn, } from "./bigcommerceStorefrontApi";
|
|
2
|
+
import { buildBigcommerceLoginUrl } from "./buildBigcommerceLoginUrl";
|
|
3
|
+
import { fetchBigCommerceCheckoutSettings } from "./fetchBigCommerceCheckoutSettings";
|
|
4
|
+
import { log } from "../logging/log";
|
|
5
|
+
const SKIP = {
|
|
6
|
+
redirectUrl: null,
|
|
7
|
+
shouldForceLogin: false,
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Session cache for the merchant-level "does BC require login?" answer.
|
|
11
|
+
* Hitting `/checkouts/settings` on every checkout open would add a visible
|
|
12
|
+
* round trip to the hot path, so we resolve it once and reuse — the setting
|
|
13
|
+
* is configured at the store level and very rarely changes.
|
|
14
|
+
*
|
|
15
|
+
* `null` means we haven't kicked off the fetch yet; the promise holds the
|
|
16
|
+
* eventual boolean so multiple concurrent callers deduplicate.
|
|
17
|
+
*/
|
|
18
|
+
let storeRequiresLoginPromise = null;
|
|
19
|
+
const resolveStoreRequiresLogin = () => {
|
|
20
|
+
if (!storeRequiresLoginPromise) {
|
|
21
|
+
const pending = fetchBigCommerceCheckoutSettings()
|
|
22
|
+
.then(({ guestCheckoutType }) => {
|
|
23
|
+
if (!guestCheckoutType) {
|
|
24
|
+
// `null` here means either the proxy call failed (transient) or the
|
|
25
|
+
// storeHash wasn't known yet. Fail open for this call, but clear
|
|
26
|
+
// the cached promise so the next caller retries instead of
|
|
27
|
+
// permanently disabling force-login for the rest of the session.
|
|
28
|
+
if (storeRequiresLoginPromise === pending) {
|
|
29
|
+
storeRequiresLoginPromise = null;
|
|
30
|
+
}
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return guestCheckoutType === 'no_guest_checkout';
|
|
34
|
+
})
|
|
35
|
+
.catch(() => {
|
|
36
|
+
// Defense-in-depth: `fetchBigCommerceCheckoutSettings` is expected to
|
|
37
|
+
// swallow its own errors, but if anything above does reject we fail
|
|
38
|
+
// open and clear the cached promise so the next caller can retry.
|
|
39
|
+
if (storeRequiresLoginPromise === pending) {
|
|
40
|
+
storeRequiresLoginPromise = null;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
});
|
|
44
|
+
storeRequiresLoginPromise = pending;
|
|
45
|
+
}
|
|
46
|
+
return storeRequiresLoginPromise;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Kick off the `/checkouts/settings` fetch in the background on page load
|
|
50
|
+
* so the result is warm by the time the shopper opens checkout. Safe to
|
|
51
|
+
* call more than once — re-invocations reuse the in-flight/resolved
|
|
52
|
+
* promise.
|
|
53
|
+
*/
|
|
54
|
+
export const initBigCommerceForceLoginCheck = () => {
|
|
55
|
+
if (!window.Zonos.isBigCommerce) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
void resolveStoreRequiresLogin();
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Decide whether the current BigCommerce shopper must sign in before the
|
|
62
|
+
* Zonos international checkout is allowed to open.
|
|
63
|
+
*
|
|
64
|
+
* Required conditions (all must hold):
|
|
65
|
+
* 1. Running on a BigCommerce storefront.
|
|
66
|
+
* 2. BC merchant has `guest_checkout_type === 'no_guest_checkout'` in their
|
|
67
|
+
* live `/v3/checkouts/settings` response.
|
|
68
|
+
* 3. Shopper has an active cart.
|
|
69
|
+
* 4. Shopper is not already logged in to BigCommerce.
|
|
70
|
+
*
|
|
71
|
+
* Returning a `redirectUrl` is an instruction, not an action: callers drive
|
|
72
|
+
* the navigation themselves so they can short-circuit any UI state (loading
|
|
73
|
+
* overlays, dialog open flags) before `window.location.href` flips.
|
|
74
|
+
*/
|
|
75
|
+
export const checkBigCommerceForceLogin = async ({ preFetched, } = {}) => {
|
|
76
|
+
if (!window.Zonos.isBigCommerce) {
|
|
77
|
+
return SKIP;
|
|
78
|
+
}
|
|
79
|
+
const requiresLogin = await resolveStoreRequiresLogin();
|
|
80
|
+
if (!requiresLogin) {
|
|
81
|
+
return SKIP;
|
|
82
|
+
}
|
|
83
|
+
const checkoutId = preFetched
|
|
84
|
+
? preFetched.checkoutId
|
|
85
|
+
: await fetchCheckoutId();
|
|
86
|
+
if (!checkoutId) {
|
|
87
|
+
// No active cart — nothing to protect. Force-login only matters once
|
|
88
|
+
// the shopper has a cart we're about to carry into Zonos checkout.
|
|
89
|
+
return SKIP;
|
|
90
|
+
}
|
|
91
|
+
const checkout = preFetched
|
|
92
|
+
? preFetched.checkout
|
|
93
|
+
: await fetchBigCommerceCheckout(checkoutId);
|
|
94
|
+
if (!checkout) {
|
|
95
|
+
// Storefront API failure — fail open so a transient outage doesn't
|
|
96
|
+
// block the shopper. The merchant's BC checkout will still enforce
|
|
97
|
+
// login server-side as a last line of defense.
|
|
98
|
+
log('BigCommerce force-login check: failed to fetch checkout data, allowing flow to continue', 'info');
|
|
99
|
+
return SKIP;
|
|
100
|
+
}
|
|
101
|
+
if (isBigCommerceCustomerLoggedIn(checkout)) {
|
|
102
|
+
return SKIP;
|
|
103
|
+
}
|
|
104
|
+
log('BigCommerce force-login check: guest shopper on no-guest-checkout store, redirecting to /login.php', 'info');
|
|
105
|
+
return {
|
|
106
|
+
redirectUrl: buildBigcommerceLoginUrl(),
|
|
107
|
+
shouldForceLogin: true,
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Test-only — resets the module-level cache so each test case starts
|
|
112
|
+
* against a clean state.
|
|
113
|
+
*/
|
|
114
|
+
export const _resetBigCommerceForceLoginCacheForTesting = () => {
|
|
115
|
+
storeRequiresLoginPromise = null;
|
|
116
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { zonosStore } from "../../store/zonosStore";
|
|
2
|
+
import { handleFetch } from "../handleFetch";
|
|
3
|
+
import { jsonParse } from "../jsonParse";
|
|
4
|
+
import { log } from "../logging/log";
|
|
5
|
+
const EMPTY = { guestCheckoutType: null };
|
|
6
|
+
/**
|
|
7
|
+
* BigCommerce's `/checkouts/settings` values almost never change after a
|
|
8
|
+
* merchant's initial setup, so we persist the result in `localStorage` and
|
|
9
|
+
* reuse it across page loads up to this TTL. Short enough that if the
|
|
10
|
+
* merchant flips `guest_checkout_type` the change still propagates within
|
|
11
|
+
* an hour.
|
|
12
|
+
*/
|
|
13
|
+
const CACHE_TTL_MS = 60 * 60 * 1000;
|
|
14
|
+
const CACHE_KEY = 'zonos--bc-checkout-settings';
|
|
15
|
+
const readFromCache = (storeHash) => {
|
|
16
|
+
try {
|
|
17
|
+
const raw = window.localStorage.getItem(CACHE_KEY);
|
|
18
|
+
if (!raw) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const parsed = jsonParse(raw);
|
|
22
|
+
if (!parsed) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
// Different store on the same origin (e.g. zonosQaUrl preview) — ignore.
|
|
26
|
+
if (parsed.storeHash !== storeHash) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
if (parsed.expiresAt < Date.now()) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return { guestCheckoutType: parsed.guestCheckoutType };
|
|
33
|
+
}
|
|
34
|
+
catch (_a) {
|
|
35
|
+
// localStorage access can throw in blocked-storage contexts (Safari
|
|
36
|
+
// private mode, cross-origin iframes) — treat as a cache miss so the
|
|
37
|
+
// network fallback runs.
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const writeToCache = (storeHash, result) => {
|
|
42
|
+
try {
|
|
43
|
+
const payload = {
|
|
44
|
+
expiresAt: Date.now() + CACHE_TTL_MS,
|
|
45
|
+
guestCheckoutType: result.guestCheckoutType,
|
|
46
|
+
storeHash,
|
|
47
|
+
};
|
|
48
|
+
window.localStorage.setItem(CACHE_KEY, JSON.stringify(payload));
|
|
49
|
+
}
|
|
50
|
+
catch (_a) {
|
|
51
|
+
// localStorage can be disabled / quota-exceeded in some browser contexts
|
|
52
|
+
// (private mode, cross-origin iframes) — drop silently since caching
|
|
53
|
+
// is only an optimization.
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Fetch the merchant's BigCommerce `/checkouts/settings` (via the demo-app
|
|
58
|
+
* proxy) so we can inspect `guest_checkout_type` from the storefront. The
|
|
59
|
+
* Store API is auth-gated, which is why we don't call it directly.
|
|
60
|
+
*
|
|
61
|
+
* Results are cached in `localStorage` for `CACHE_TTL_MS` so navigations
|
|
62
|
+
* inside the same store don't all pay the proxy round trip — the setting
|
|
63
|
+
* is merchant-level and rarely changes.
|
|
64
|
+
*/
|
|
65
|
+
export const fetchBigCommerceCheckoutSettings = async () => {
|
|
66
|
+
var _a;
|
|
67
|
+
if (!window.Zonos.isBigCommerce) {
|
|
68
|
+
return EMPTY;
|
|
69
|
+
}
|
|
70
|
+
const storeHash = (_a = zonosStore.checkoutSettings.bigCommerceConfig) === null || _a === void 0 ? void 0 : _a.storeHash;
|
|
71
|
+
if (!storeHash) {
|
|
72
|
+
log('BigCommerce checkout settings: no storeHash provided — skipping fetch', 'info');
|
|
73
|
+
return EMPTY;
|
|
74
|
+
}
|
|
75
|
+
const cached = readFromCache(storeHash);
|
|
76
|
+
if (cached) {
|
|
77
|
+
return cached;
|
|
78
|
+
}
|
|
79
|
+
const { errors, json } = await handleFetch('/api/bigcommerce/checkout-settings', {
|
|
80
|
+
body: { storeHash },
|
|
81
|
+
method: 'POST',
|
|
82
|
+
});
|
|
83
|
+
if (errors.length || !json) {
|
|
84
|
+
log('BigCommerce checkout settings: proxy call failed, falling back to guest-allowed behavior', 'info');
|
|
85
|
+
return EMPTY;
|
|
86
|
+
}
|
|
87
|
+
const result = {
|
|
88
|
+
guestCheckoutType: json.guestCheckoutType,
|
|
89
|
+
};
|
|
90
|
+
writeToCache(storeHash, result);
|
|
91
|
+
return result;
|
|
92
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { buildBigcommerceLoginUrl } from "./buildBigcommerceLoginUrl";
|
|
2
|
+
/**
|
|
3
|
+
* Mark we've already rewritten a given anchor so the MutationObserver
|
|
4
|
+
* doesn't loop on its own mutation.
|
|
5
|
+
*/
|
|
6
|
+
const REWRITTEN_ATTR = 'data-zonos-login-from-rewritten';
|
|
7
|
+
const CREATE_ACCOUNT_SELECTOR = 'a[href*="login.php?action=create_account"]:not([' + REWRITTEN_ATTR + '])';
|
|
8
|
+
const rewriteCreateAccountLinks = () => {
|
|
9
|
+
const anchors = document.querySelectorAll(CREATE_ACCOUNT_SELECTOR);
|
|
10
|
+
if (!anchors.length) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const target = buildBigcommerceLoginUrl({ action: 'create_account' });
|
|
14
|
+
anchors.forEach(anchor => {
|
|
15
|
+
anchor.setAttribute('href', target);
|
|
16
|
+
anchor.setAttribute(REWRITTEN_ATTR, 'true');
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* On BigCommerce's `/login.php`, the default **Create account** button links
|
|
21
|
+
* to `login.php?action=create_account` without the `from=cart.php...`
|
|
22
|
+
* parameter that the shopper had when they arrived. Without this, completing
|
|
23
|
+
* signup would drop them on the account home page instead of resuming Zonos
|
|
24
|
+
* international checkout.
|
|
25
|
+
*
|
|
26
|
+
* This watcher finds any create-account anchor on the page (including ones
|
|
27
|
+
* that the BC theme renders later via Stencil bundle load) and rewrites the
|
|
28
|
+
* `href` so the account-creation round trip preserves the
|
|
29
|
+
* `isInternationalCheckout=true` flag as well as `zonosTestMode` /
|
|
30
|
+
* `zonosQaUrl`.
|
|
31
|
+
*
|
|
32
|
+
* Safe to call more than once — idempotent thanks to the `data-zonos-…`
|
|
33
|
+
* attribute on rewritten anchors.
|
|
34
|
+
*/
|
|
35
|
+
export const fixBigCommerceLoginCreateAccountLink = () => {
|
|
36
|
+
if (!window.Zonos.isBigCommerce) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!window.location.pathname.includes('/login.php')) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
rewriteCreateAccountLinks();
|
|
43
|
+
// BC's login page often renders the auth form asynchronously, so the
|
|
44
|
+
// anchor may not exist yet when this runs. Observe for a short window,
|
|
45
|
+
// then stop so we don't leak a listener for the rest of the session.
|
|
46
|
+
const observer = new MutationObserver(() => {
|
|
47
|
+
rewriteCreateAccountLinks();
|
|
48
|
+
});
|
|
49
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
50
|
+
// 10 seconds is plenty for the login form to mount; stopping the observer
|
|
51
|
+
// avoids churn from the rest of the page's normal DOM activity.
|
|
52
|
+
setTimeout(() => observer.disconnect(), 10000);
|
|
53
|
+
};
|
|
@@ -4,6 +4,7 @@ import { zonosStore } from "../../store/zonosStore";
|
|
|
4
4
|
import { fetchBigCommerceCheckout, fetchCheckoutId, } from "./bigcommerceStorefrontApi";
|
|
5
5
|
import { buildBigcommerceRedirectUrl } from "./buildBigcommerceRedirectUrl";
|
|
6
6
|
import { checkBigCommerceBypassCustomerGroup } from "./checkBigCommerceBypassCustomerGroup";
|
|
7
|
+
import { checkBigCommerceForceLogin } from "./checkBigCommerceForceLogin";
|
|
7
8
|
import { isShippableCountry } from "./isShippableCountry";
|
|
8
9
|
import { log } from "../logging/log";
|
|
9
10
|
import { logError } from "../logging/logError";
|
|
@@ -16,19 +17,27 @@ const FALLBACK_SHIP_TO_COUNTRY_SELECTOR = 'select[name="shippingAddress.countryC
|
|
|
16
17
|
*/
|
|
17
18
|
const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelected, onLoggedInInternationalAddressDetected, }) => {
|
|
18
19
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
20
|
+
// Fetch the Storefront API data once up front and thread it through every
|
|
21
|
+
// decision below (bypass, shipping-address inspection, force-login). The
|
|
22
|
+
// function always needs the checkout for the address check, so reusing one
|
|
23
|
+
// fetch avoids the earlier 4x round-trip fan-out where bypass, address
|
|
24
|
+
// lookup, and force-login each fetched independently.
|
|
25
|
+
const checkoutId = await fetchCheckoutId();
|
|
26
|
+
if (!checkoutId) {
|
|
27
|
+
return 'noAction';
|
|
28
|
+
}
|
|
29
|
+
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
30
|
+
const preFetched = { checkout, checkoutId };
|
|
19
31
|
// Check if the customer belongs to a bypass group (e.g. resellers) before
|
|
20
32
|
// redirecting them away from BigCommerce native checkout. This delegates to
|
|
21
33
|
// the shared helper so the bypass decision has a single source of truth and
|
|
22
34
|
// reuses the cached promise warmed by `initBigCommerceBypassCheck`.
|
|
23
|
-
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup(
|
|
35
|
+
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup({
|
|
36
|
+
preFetched,
|
|
37
|
+
});
|
|
24
38
|
if (shouldBypass) {
|
|
25
39
|
return 'noAction';
|
|
26
40
|
}
|
|
27
|
-
const checkoutId = await fetchCheckoutId();
|
|
28
|
-
if (!checkoutId) {
|
|
29
|
-
return 'noAction';
|
|
30
|
-
}
|
|
31
|
-
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
32
41
|
const shippingAddress = (_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.consignments) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.shippingAddress;
|
|
33
42
|
if (!(shippingAddress === null || shippingAddress === void 0 ? void 0 : shippingAddress.countryCode)) {
|
|
34
43
|
return 'noAction';
|
|
@@ -51,6 +60,14 @@ const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelecte
|
|
|
51
60
|
return 'optedOut';
|
|
52
61
|
}
|
|
53
62
|
}
|
|
63
|
+
// Force-login merchants must sign the guest shopper in before we leave
|
|
64
|
+
// BC's native checkout. Reuse the checkout we already fetched above so we
|
|
65
|
+
// don't double up on Storefront API round trips.
|
|
66
|
+
const forceLogin = await checkBigCommerceForceLogin({ preFetched });
|
|
67
|
+
if (forceLogin.shouldForceLogin && forceLogin.redirectUrl) {
|
|
68
|
+
window.location.href = forceLogin.redirectUrl;
|
|
69
|
+
return 'redirected';
|
|
70
|
+
}
|
|
54
71
|
if (onInternationalCheckoutSelected) {
|
|
55
72
|
await onInternationalCheckoutSelected();
|
|
56
73
|
}
|
|
@@ -108,9 +125,17 @@ export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedi
|
|
|
108
125
|
// Only check bypass after confirming the country is shippable (i.e. user is
|
|
109
126
|
// about to be redirected to Zonos international checkout). Force-refresh so
|
|
110
127
|
// we re-fetch BigCommerce checkout data every time the ship-to country
|
|
111
|
-
// changes — prevents stale customer-group data from a cached fetch.
|
|
128
|
+
// changes — prevents stale customer-group data from a cached fetch. Share
|
|
129
|
+
// one fetch between the bypass and force-login decisions so this poll
|
|
130
|
+
// tick does 2 Storefront API round trips instead of 4.
|
|
131
|
+
const checkoutId = await fetchCheckoutId();
|
|
132
|
+
const checkout = checkoutId
|
|
133
|
+
? await fetchBigCommerceCheckout(checkoutId)
|
|
134
|
+
: null;
|
|
135
|
+
const preFetched = { checkout, checkoutId };
|
|
112
136
|
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup({
|
|
113
137
|
forceRefresh: true,
|
|
138
|
+
preFetched,
|
|
114
139
|
});
|
|
115
140
|
if (shouldBypass) {
|
|
116
141
|
// Logged-in customer is in a bypass group — keep them on BC native
|
|
@@ -118,6 +143,14 @@ export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedi
|
|
|
118
143
|
log('Bypass customer group detected on BC checkout, stopping interval', 'info');
|
|
119
144
|
return true;
|
|
120
145
|
}
|
|
146
|
+
// Same force-login gate as the logged-in-default-address path — we run
|
|
147
|
+
// it *after* the bypass check so reseller groups never see the login
|
|
148
|
+
// bounce, and *before* any UI/session state flips to the redirect.
|
|
149
|
+
const forceLogin = await checkBigCommerceForceLogin({ preFetched });
|
|
150
|
+
if (forceLogin.shouldForceLogin && forceLogin.redirectUrl) {
|
|
151
|
+
window.location.href = forceLogin.redirectUrl;
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
121
154
|
if (onInternationalCheckoutSelected) {
|
|
122
155
|
await onInternationalCheckoutSelected();
|
|
123
156
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|