@zonos/elements 1.3.254 → 1.3.256
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/{cart-77640463.js → cart-e156c1e3.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-e93c64fd.js → hasInclusivePrice-d6d274bd.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-211ef96c.js → invoice-f4b5d538.js} +2 -2
- package/dist/cjs/{isCollectMobileTablet-14fb5ab4.js → isCollectMobileTablet-c9369cd8.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{localization-be7afc1b.js → localization-5bb1e598.js} +243 -0
- package/dist/cjs/{paypal-c61ef042.js → paypal-f9641595.js} +2 -2
- package/dist/cjs/{placeTestOrder-0f7477c8.js → placeTestOrder-7ac7f91a.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-1ac02803.js → renderCheckoutCurrency-6b59a718.js} +2 -2
- package/dist/cjs/zonos-address-display_8.cjs.entry.js +2 -2
- package/dist/cjs/zonos-address_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-card_5.cjs.entry.js +3 -3
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +6 -6
- package/dist/cjs/zonos-checkout.cjs.entry.js +357 -78
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +2 -2
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +6 -6
- package/dist/cjs/zonos-collect.cjs.entry.js +4 -4
- package/dist/cjs/zonos-controller.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-flag.cjs.entry.js +1 -1
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +1 -1
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +4 -4
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +6 -6
- package/dist/cjs/zonos-invoice.cjs.entry.js +4 -4
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-store-credit.cjs.entry.js +3 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +60 -2
- package/dist/collection/components/store/hello/localization.js +3 -0
- package/dist/collection/components/store/translationStore/strings.arabic.js +12 -0
- package/dist/collection/components/store/translationStore/strings.base.js +12 -0
- package/dist/collection/components/store/translationStore/strings.chinese.js +12 -0
- package/dist/collection/components/store/translationStore/strings.danish.js +12 -0
- package/dist/collection/components/store/translationStore/strings.dutch.js +12 -0
- package/dist/collection/components/store/translationStore/strings.french.js +12 -0
- package/dist/collection/components/store/translationStore/strings.german.js +12 -0
- package/dist/collection/components/store/translationStore/strings.hebrew.js +12 -0
- package/dist/collection/components/store/translationStore/strings.indonesian.js +12 -0
- package/dist/collection/components/store/translationStore/strings.italian.js +12 -0
- package/dist/collection/components/store/translationStore/strings.japanese.js +12 -0
- package/dist/collection/components/store/translationStore/strings.korean.js +12 -0
- package/dist/collection/components/store/translationStore/strings.norwegian.js +12 -0
- package/dist/collection/components/store/translationStore/strings.polish.js +12 -0
- package/dist/collection/components/store/translationStore/strings.portuguese.js +12 -0
- package/dist/collection/components/store/translationStore/strings.russian.js +12 -0
- package/dist/collection/components/store/translationStore/strings.spanish.js +12 -0
- package/dist/collection/components/store/translationStore/strings.swedish.js +12 -0
- package/dist/collection/components/store/translationStore/strings.turkish.js +12 -0
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +12 -0
- package/dist/collection/components/utils/checkout/bigcommerceStorefrontApi.js +52 -0
- package/dist/collection/components/utils/checkout/buildBigcommerceRedirectUrl.js +22 -0
- package/dist/collection/components/utils/checkout/checkBigCommerceBypassCustomerGroup.js +122 -0
- package/dist/collection/components/utils/checkout/watchBigcommerceDomesticCheckout.js +5 -2
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +120 -86
- package/dist/esm/{cart-394c9ddb.js → cart-55b8dd7c.js} +1 -1
- package/dist/esm/{hasInclusivePrice-f0322e1c.js → hasInclusivePrice-ddae18fd.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-5ae81ae5.js → invoice-dbe85a18.js} +2 -2
- package/dist/esm/{isCollectMobileTablet-15b668d6.js → isCollectMobileTablet-8af0d16d.js} +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{localization-0ebc8356.js → localization-d11c973f.js} +243 -0
- package/dist/esm/{paypal-b6fa3ec3.js → paypal-f87fbee0.js} +2 -2
- package/dist/esm/{placeTestOrder-5756cbc3.js → placeTestOrder-8e8e97be.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-5f3e06ea.js → renderCheckoutCurrency-45c74af2.js} +2 -2
- package/dist/esm/zonos-address-display_8.entry.js +2 -2
- package/dist/esm/zonos-address_4.entry.js +2 -2
- package/dist/esm/zonos-card_5.entry.js +3 -3
- package/dist/esm/zonos-cart-items_12.entry.js +6 -6
- package/dist/esm/zonos-checkout.entry.js +358 -79
- package/dist/esm/zonos-collect-cart-items_3.entry.js +2 -2
- package/dist/esm/zonos-collect-finish_6.entry.js +6 -6
- package/dist/esm/zonos-collect.entry.js +4 -4
- package/dist/esm/zonos-controller.entry.js +2 -2
- package/dist/esm/zonos-country-flag.entry.js +1 -1
- package/dist/esm/zonos-country-select_4.entry.js +1 -1
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +2 -2
- package/dist/esm/zonos-hello.entry.js +1 -1
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +4 -4
- package/dist/esm/zonos-invoice-finish_5.entry.js +6 -6
- package/dist/esm/zonos-invoice.entry.js +4 -4
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm/zonos-store-credit.entry.js +3 -3
- package/dist/esm-es5/{cart-394c9ddb.js → cart-55b8dd7c.js} +1 -1
- package/dist/esm-es5/{hasInclusivePrice-f0322e1c.js → hasInclusivePrice-ddae18fd.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-5ae81ae5.js → invoice-dbe85a18.js} +1 -1
- package/dist/esm-es5/{isCollectMobileTablet-15b668d6.js → isCollectMobileTablet-8af0d16d.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/localization-d11c973f.js +1 -0
- package/dist/esm-es5/{paypal-b6fa3ec3.js → paypal-f87fbee0.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-5756cbc3.js → placeTestOrder-8e8e97be.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-5f3e06ea.js → renderCheckoutCurrency-45c74af2.js} +1 -1
- package/dist/esm-es5/zonos-address-display_8.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +1 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +1 -1
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-store-credit.entry.js +1 -1
- package/dist/scripts/index.d.ts +19 -0
- 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 +13 -0
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.base.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.danish.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.french.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.german.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.italian.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.korean.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.polish.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.russian.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +12 -0
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +12 -0
- package/dist/types/components/utils/checkout/bigcommerceStorefrontApi.d.ts +36 -0
- package/dist/types/components/utils/checkout/buildBigcommerceRedirectUrl.d.ts +11 -0
- package/dist/types/components/utils/checkout/checkBigCommerceBypassCustomerGroup.d.ts +30 -0
- package/dist/types/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.d.ts +16 -1
- package/dist/types/types/utils/ZonosSettings.d.ts +7 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-bdaf2a38.entry.js → p-00728af1.entry.js} +1 -1
- package/dist/zonos-elements/{p-4a38ea5e.system.entry.js → p-08830a50.system.entry.js} +1 -1
- package/dist/zonos-elements/p-179bbeae.js +1 -0
- package/dist/zonos-elements/{p-b49b8da4.system.entry.js → p-1c9e9692.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-97fb5ad5.entry.js → p-225957b9.entry.js} +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/{p-27fad55a.system.js → p-2a28c7ac.system.js} +1 -1
- package/dist/zonos-elements/{p-92d91395.system.entry.js → p-2cb5ef7d.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b37a85f0.system.entry.js → p-2eeda8a9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0da3cc62.system.entry.js → p-32365d6a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-11d6de1a.entry.js → p-399f5ad6.entry.js} +1 -1
- package/dist/zonos-elements/{p-57b27c60.js → p-3a8925e9.js} +1 -1
- package/dist/zonos-elements/p-3f141999.system.js +1 -0
- package/dist/zonos-elements/{p-620ba943.js → p-3fae811a.js} +1 -1
- package/dist/zonos-elements/{p-93dec11b.entry.js → p-50d31f4f.entry.js} +1 -1
- package/dist/zonos-elements/{p-c6047442.system.entry.js → p-52b70520.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a0ac3ca2.system.entry.js → p-53275a0d.system.entry.js} +1 -1
- package/dist/zonos-elements/p-5343c32b.system.js +1 -0
- package/dist/zonos-elements/{p-09d7a5cb.system.js → p-57b5d3e3.system.js} +1 -1
- package/dist/zonos-elements/{p-daaaa8f1.system.entry.js → p-59025df9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a1e23675.system.entry.js → p-5d0b0126.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8dfa0bb8.system.entry.js → p-664aff48.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c1ae7391.system.entry.js → p-6b45e9f3.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-321e7920.system.js → p-70e069d3.system.js} +1 -1
- package/dist/zonos-elements/{p-fce715f1.system.entry.js → p-72de2fdc.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8abeab5a.entry.js → p-7d4a1565.entry.js} +1 -1
- package/dist/zonos-elements/{p-07ca3347.system.entry.js → p-8608c123.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-615b5d13.entry.js → p-89757efe.entry.js} +1 -1
- package/dist/zonos-elements/{p-920d9189.entry.js → p-8a593061.entry.js} +1 -1
- package/dist/zonos-elements/{p-efa69c89.entry.js → p-8ccf97ce.entry.js} +1 -1
- package/dist/zonos-elements/{p-4f23732f.js → p-93c64387.js} +1 -1
- package/dist/zonos-elements/p-93d6e13f.entry.js +1 -0
- package/dist/zonos-elements/p-9631c373.system.js +1 -0
- package/dist/zonos-elements/p-99e1734a.js +1 -0
- package/dist/zonos-elements/{p-a5adc047.system.entry.js → p-9b42f0ad.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8efb79ab.entry.js → p-aad014df.entry.js} +1 -1
- package/dist/zonos-elements/p-ae397ff8.system.entry.js +1 -0
- package/dist/zonos-elements/{p-d65cfa9b.system.entry.js → p-b439d38f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-2bdc2206.entry.js → p-b85d4286.entry.js} +1 -1
- package/dist/zonos-elements/{p-2c2e5ee6.entry.js → p-befad3c4.entry.js} +1 -1
- package/dist/zonos-elements/{p-a5fb864a.system.entry.js → p-c66649fe.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d8610393.entry.js → p-d14e5c81.entry.js} +1 -1
- package/dist/zonos-elements/{p-a95ac160.entry.js → p-d155b9c6.entry.js} +1 -1
- package/dist/zonos-elements/{p-dcef3647.system.js → p-d280e9b6.system.js} +1 -1
- package/dist/zonos-elements/{p-9ff90151.entry.js → p-dba635e6.entry.js} +1 -1
- package/dist/zonos-elements/{p-1162b685.entry.js → p-ddde268d.entry.js} +1 -1
- package/dist/zonos-elements/p-e2adf04b.system.js +1 -0
- package/dist/zonos-elements/p-ee2c7a1e.js +1 -0
- package/dist/zonos-elements/{p-3d757163.entry.js → p-f36e907e.entry.js} +1 -1
- package/dist/zonos-elements/{p-29f7950c.js → p-f6733ffb.js} +1 -1
- package/dist/zonos-elements/{p-95f7f2a0.entry.js → p-f9ffff4e.entry.js} +1 -1
- package/dist/zonos-elements/p-fa0c5017.js +1 -0
- package/dist/zonos-elements/{p-fbccfa3e.system.js → p-fbd44c55.system.js} +1 -1
- package/dist/zonos-elements/{p-c2121663.system.entry.js → p-fc1c7fe5.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/esm-es5/localization-0ebc8356.js +0 -1
- package/dist/zonos-elements/p-0dd5a4b8.system.js +0 -1
- package/dist/zonos-elements/p-1282495f.system.js +0 -1
- package/dist/zonos-elements/p-13041752.js +0 -1
- package/dist/zonos-elements/p-2b118454.js +0 -1
- package/dist/zonos-elements/p-2c9c750e.system.js +0 -1
- package/dist/zonos-elements/p-4df85216.entry.js +0 -1
- package/dist/zonos-elements/p-ac353826.js +0 -1
- package/dist/zonos-elements/p-ca19a10a.js +0 -1
- package/dist/zonos-elements/p-cc9620e5.system.entry.js +0 -1
- package/dist/zonos-elements/p-cf69bcc4.system.js +0 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { log } from "../logging/log";
|
|
2
|
+
import { logError } from "../logging/logError";
|
|
3
|
+
/**
|
|
4
|
+
* Fetch the checkout/cart ID from the BigCommerce Storefront Cart API.
|
|
5
|
+
* The `/checkout` page URL does not include the checkout ID, so we
|
|
6
|
+
* retrieve it from `/api/storefront/cart` which returns the active cart(s).
|
|
7
|
+
*/
|
|
8
|
+
export const fetchCheckoutId = async () => {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
try {
|
|
11
|
+
const response = await fetch('/api/storefront/cart', {
|
|
12
|
+
credentials: 'same-origin',
|
|
13
|
+
headers: {
|
|
14
|
+
Accept: 'application/json',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
log(`Failed to fetch BigCommerce cart: ${String(response.status)}`, 'error');
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
const carts = (await response.json());
|
|
22
|
+
return (_b = (_a = carts === null || carts === void 0 ? void 0 : carts[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
logError('Error fetching BigCommerce cart data', error);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Fetch checkout data from the BigCommerce Storefront API.
|
|
31
|
+
* This API is cookie-authenticated (same-origin), so no token is needed.
|
|
32
|
+
*/
|
|
33
|
+
export const fetchBigCommerceCheckout = async (checkoutId) => {
|
|
34
|
+
try {
|
|
35
|
+
const response = await fetch(`/api/storefront/checkouts/${checkoutId}?include=customer.customerGroup`, {
|
|
36
|
+
credentials: 'same-origin',
|
|
37
|
+
headers: {
|
|
38
|
+
Accept: 'application/json',
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
if (!response.ok) {
|
|
43
|
+
log(`Failed to fetch BigCommerce checkout: ${String(response.status)}`, 'error');
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return (await response.json());
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
logError('Error fetching BigCommerce checkout data', error);
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getIsTestMode } from "./getIsTestMode";
|
|
2
|
+
/**
|
|
3
|
+
* Build an absolute redirect URL used by the BigCommerce checkout flows to
|
|
4
|
+
* navigate between the BC native `/checkout` page and the Zonos international
|
|
5
|
+
* checkout at `/`.
|
|
6
|
+
*
|
|
7
|
+
* Carries over the `zonosQaUrl` query param from the current URL (when
|
|
8
|
+
* present) so the preview Zonos elements build keeps loading after the
|
|
9
|
+
* redirect, and sets `zonosTestMode=1` when test mode is active so the
|
|
10
|
+
* destination page continues to use the test credentials.
|
|
11
|
+
*/
|
|
12
|
+
export const buildBigcommerceRedirectUrl = (pathname) => {
|
|
13
|
+
const url = new URL(pathname, window.location.origin);
|
|
14
|
+
const zonosQaUrl = new URLSearchParams(window.location.search).get('zonosQaUrl');
|
|
15
|
+
if (zonosQaUrl) {
|
|
16
|
+
url.searchParams.set('zonosQaUrl', zonosQaUrl);
|
|
17
|
+
}
|
|
18
|
+
if (getIsTestMode()) {
|
|
19
|
+
url.searchParams.set('zonosTestMode', '1');
|
|
20
|
+
}
|
|
21
|
+
return url.toString();
|
|
22
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { zonosStore } from "../../store/zonosStore";
|
|
2
|
+
import { fetchBigCommerceCheckout, fetchCheckoutId, } from "./bigcommerceStorefrontApi";
|
|
3
|
+
import { log } from "../logging/log";
|
|
4
|
+
const DEFAULT_RESULT = {
|
|
5
|
+
customerGroupId: null,
|
|
6
|
+
shouldBypass: false,
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Performs the actual fetch logic to determine if the customer
|
|
10
|
+
* belongs to a bypass group.
|
|
11
|
+
*/
|
|
12
|
+
const fetchBypassOutcome = async () => {
|
|
13
|
+
var _a, _b, _c, _d;
|
|
14
|
+
// Only relevant for BigCommerce stores — permanent no-op on other platforms
|
|
15
|
+
if (!window.Zonos.isBigCommerce) {
|
|
16
|
+
return { conclusive: true, result: DEFAULT_RESULT };
|
|
17
|
+
}
|
|
18
|
+
const bypassGroupIds = (_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.bigcommerceBypassCustomerGroupIds;
|
|
19
|
+
if (!(bypassGroupIds === null || bypassGroupIds === void 0 ? void 0 : bypassGroupIds.length)) {
|
|
20
|
+
if (zonosStore.loadedConfig) {
|
|
21
|
+
// Settings have finished loading and there are no bypass groups
|
|
22
|
+
// configured — this is a permanent "bypass not configured" answer.
|
|
23
|
+
return { conclusive: true, result: DEFAULT_RESULT };
|
|
24
|
+
}
|
|
25
|
+
// Settings haven't loaded yet — the empty list may be transient.
|
|
26
|
+
// Mark as inconclusive so a later caller retries after config loads.
|
|
27
|
+
return { conclusive: false, result: DEFAULT_RESULT };
|
|
28
|
+
}
|
|
29
|
+
// Fetch customer group from BigCommerce Storefront API
|
|
30
|
+
const checkoutId = await fetchCheckoutId();
|
|
31
|
+
if (!checkoutId) {
|
|
32
|
+
// No active cart yet — inconclusive. Common on fresh sessions where
|
|
33
|
+
// `initBigCommerceBypassCheck` runs before the user has added anything
|
|
34
|
+
// to their cart; once the cart exists we need to re-fetch.
|
|
35
|
+
log('BigCommerce bypass check: no active cart yet, will retry on next call', 'info');
|
|
36
|
+
return { conclusive: false, result: DEFAULT_RESULT };
|
|
37
|
+
}
|
|
38
|
+
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
39
|
+
if (!checkout) {
|
|
40
|
+
// API call failed (network error, non-200, etc.) — inconclusive.
|
|
41
|
+
// Caching this would permanently disable bypass for the session if
|
|
42
|
+
// the logged-in user is actually a reseller.
|
|
43
|
+
log('BigCommerce bypass check: failed to fetch checkout data, will retry', 'info');
|
|
44
|
+
return { conclusive: false, result: DEFAULT_RESULT };
|
|
45
|
+
}
|
|
46
|
+
const customerGroupId = (_d = (_c = (_b = checkout.customer) === null || _b === void 0 ? void 0 : _b.customerGroup) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : null;
|
|
47
|
+
if (customerGroupId === null) {
|
|
48
|
+
log('BigCommerce bypass check: no customer group found (guest user)', 'info');
|
|
49
|
+
// Guest user with an active cart — a definitive "no bypass" answer.
|
|
50
|
+
return { conclusive: true, result: DEFAULT_RESULT };
|
|
51
|
+
}
|
|
52
|
+
const shouldBypass = bypassGroupIds.includes(customerGroupId);
|
|
53
|
+
const result = { customerGroupId, shouldBypass };
|
|
54
|
+
if (shouldBypass) {
|
|
55
|
+
log(`BigCommerce bypass check: customer group ${String(customerGroupId)} is in bypass list; caller should keep the user on BC native checkout`, 'info');
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
log(`BigCommerce bypass check: customer group ${String(customerGroupId)} is not in bypass list`, 'info');
|
|
59
|
+
}
|
|
60
|
+
return { conclusive: true, result };
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Module-level promise that holds the in-flight or resolved bypass check.
|
|
64
|
+
* Set by `initBigCommerceBypassCheck` on page load so the result is ready
|
|
65
|
+
* by the time checkout opens or the watcher fires.
|
|
66
|
+
*
|
|
67
|
+
* Automatically invalidated when a fetch resolves to an inconclusive outcome,
|
|
68
|
+
* so subsequent callers retry (e.g. after the user adds an item to their
|
|
69
|
+
* cart or after settings finish loading).
|
|
70
|
+
*/
|
|
71
|
+
let bypassCheckPromise = null;
|
|
72
|
+
const startBypassCheck = () => {
|
|
73
|
+
const outcomePromise = fetchBypassOutcome();
|
|
74
|
+
const resultPromise = outcomePromise.then(({ conclusive, result }) => {
|
|
75
|
+
if (!conclusive && bypassCheckPromise === resultPromise) {
|
|
76
|
+
// Invalidate cache so the next caller performs a fresh fetch.
|
|
77
|
+
bypassCheckPromise = null;
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
});
|
|
81
|
+
bypassCheckPromise = resultPromise;
|
|
82
|
+
return resultPromise;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Start fetching the BigCommerce customer group on page load.
|
|
86
|
+
* Call this once during initialization (e.g. in `zonos-checkout.init()`).
|
|
87
|
+
* The fetch runs in the background; `checkBigCommerceBypassCustomerGroup`
|
|
88
|
+
* will await the result when needed.
|
|
89
|
+
*/
|
|
90
|
+
export const initBigCommerceBypassCheck = () => {
|
|
91
|
+
var _a;
|
|
92
|
+
if (!window.Zonos.isBigCommerce) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const bypassGroupIds = (_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.bigcommerceBypassCustomerGroupIds;
|
|
96
|
+
if (!(bypassGroupIds === null || bypassGroupIds === void 0 ? void 0 : bypassGroupIds.length)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
// Fire the fetch immediately; consumers will await the same promise
|
|
100
|
+
void startBypassCheck();
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Check if the current BigCommerce customer belongs to a customer group
|
|
104
|
+
* that should bypass Zonos Checkout.
|
|
105
|
+
*
|
|
106
|
+
* If `initBigCommerceBypassCheck` was called on page load and the resulting
|
|
107
|
+
* outcome was conclusive, this returns the already-resolved (or in-flight)
|
|
108
|
+
* result without making additional API calls. If the previous outcome was
|
|
109
|
+
* inconclusive (no cart, settings not loaded), the cache was invalidated
|
|
110
|
+
* automatically and this triggers a fresh fetch.
|
|
111
|
+
*
|
|
112
|
+
* @param options.forceRefresh - When true, bypasses any cached result and
|
|
113
|
+
* always fetches fresh BigCommerce checkout data. Use this on the
|
|
114
|
+
* BigCommerce domestic checkout page when the shipping country changes,
|
|
115
|
+
* to ensure the customer group reflects the current checkout state.
|
|
116
|
+
*/
|
|
117
|
+
export const checkBigCommerceBypassCustomerGroup = async (options = {}) => {
|
|
118
|
+
if (options.forceRefresh || !bypassCheckPromise) {
|
|
119
|
+
return startBypassCheck();
|
|
120
|
+
}
|
|
121
|
+
return bypassCheckPromise;
|
|
122
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { stripeStoreCleanupDomesticShippingSession, stripeStoreGetDomesticShippingSession, stripeStoreSaveDomesticShippingSession, } from "../../store/checkout/stripe";
|
|
2
2
|
import { localizationStoreUpdateSelectedCountryCode } from "../../store/hello/localization";
|
|
3
3
|
import { zonosStore } from "../../store/zonosStore";
|
|
4
|
+
import { buildBigcommerceRedirectUrl } from "./buildBigcommerceRedirectUrl";
|
|
4
5
|
import { isShippableCountry } from "./isShippableCountry";
|
|
5
6
|
import { logError } from "../logging/logError";
|
|
6
7
|
import { sendErrorLog } from "../logging/sendErrorLog";
|
|
@@ -102,8 +103,10 @@ export const watchBigcommerceDomesticCheckout = ({ domesticRedirectedBtnSelector
|
|
|
102
103
|
});
|
|
103
104
|
e.preventDefault();
|
|
104
105
|
e.stopPropagation();
|
|
105
|
-
// redirect to home page, home page then will open the checkout dialog if
|
|
106
|
-
|
|
106
|
+
// redirect to home page, home page then will open the checkout dialog if
|
|
107
|
+
// having domestic shipping session. Carry over zonosQaUrl / zonosTestMode
|
|
108
|
+
// so the destination page keeps using the same build/env.
|
|
109
|
+
window.location.href = buildBigcommerceRedirectUrl('/');
|
|
107
110
|
});
|
|
108
111
|
});
|
|
109
112
|
observer.observe(document.body, {
|
|
@@ -1,81 +1,56 @@
|
|
|
1
1
|
import { stripeStoreGetDomesticShippingSession, stripeStoreSaveDomesticShippingSession, } from "../../store/checkout/stripe";
|
|
2
2
|
import { localizationStoreUpdateSelectedCountryCode } from "../../store/hello/localization";
|
|
3
3
|
import { zonosStore } from "../../store/zonosStore";
|
|
4
|
+
import { fetchBigCommerceCheckout, fetchCheckoutId, } from "./bigcommerceStorefrontApi";
|
|
5
|
+
import { buildBigcommerceRedirectUrl } from "./buildBigcommerceRedirectUrl";
|
|
6
|
+
import { checkBigCommerceBypassCustomerGroup } from "./checkBigCommerceBypassCustomerGroup";
|
|
4
7
|
import { isShippableCountry } from "./isShippableCountry";
|
|
5
8
|
import { log } from "../logging/log";
|
|
6
9
|
import { logError } from "../logging/logError";
|
|
7
10
|
const FALLBACK_SHIP_TO_COUNTRY_SELECTOR = 'select[name="shippingAddress.countryCode"]';
|
|
8
|
-
/**
|
|
9
|
-
* Fetch the checkout/cart ID from the BigCommerce Storefront Cart API.
|
|
10
|
-
* The `/checkout` page URL does not include the checkout ID, so we
|
|
11
|
-
* retrieve it from `/api/storefront/cart` which returns the active cart(s).
|
|
12
|
-
*/
|
|
13
|
-
const fetchCheckoutId = async () => {
|
|
14
|
-
var _a, _b;
|
|
15
|
-
try {
|
|
16
|
-
const response = await fetch('/api/storefront/cart', {
|
|
17
|
-
credentials: 'same-origin',
|
|
18
|
-
headers: {
|
|
19
|
-
Accept: 'application/json',
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
if (!response.ok) {
|
|
23
|
-
log(`Failed to fetch BigCommerce cart: ${String(response.status)}`, 'error');
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
const carts = (await response.json());
|
|
27
|
-
return (_b = (_a = carts === null || carts === void 0 ? void 0 : carts[0]) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null;
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
logError('Error fetching BigCommerce cart data', error);
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Fetch checkout data from the BigCommerce Storefront API.
|
|
36
|
-
* This API is cookie-authenticated (same-origin), so no token is needed.
|
|
37
|
-
*/
|
|
38
|
-
const fetchBigCommerceCheckout = async (checkoutId) => {
|
|
39
|
-
try {
|
|
40
|
-
const response = await fetch(`/api/storefront/checkouts/${checkoutId}`, {
|
|
41
|
-
credentials: 'same-origin',
|
|
42
|
-
headers: {
|
|
43
|
-
Accept: 'application/json',
|
|
44
|
-
'Content-Type': 'application/json',
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
if (!response.ok) {
|
|
48
|
-
log(`Failed to fetch BigCommerce checkout: ${String(response.status)}`, 'error');
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return (await response.json());
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
logError('Error fetching BigCommerce checkout data', error);
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
11
|
/**
|
|
59
12
|
* Check if the logged-in user already has a shipping address on the checkout
|
|
60
|
-
* that is internationally shippable. If so,
|
|
61
|
-
*
|
|
13
|
+
* that is internationally shippable. If so, optionally prompt the user to
|
|
14
|
+
* confirm before saving the address to session and redirecting to the home
|
|
15
|
+
* page to open the international checkout.
|
|
62
16
|
*/
|
|
63
|
-
const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelected, }) => {
|
|
17
|
+
const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelected, onLoggedInInternationalAddressDetected, }) => {
|
|
64
18
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
19
|
+
// Check if the customer belongs to a bypass group (e.g. resellers) before
|
|
20
|
+
// redirecting them away from BigCommerce native checkout. This delegates to
|
|
21
|
+
// the shared helper so the bypass decision has a single source of truth and
|
|
22
|
+
// reuses the cached promise warmed by `initBigCommerceBypassCheck`.
|
|
23
|
+
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup();
|
|
24
|
+
if (shouldBypass) {
|
|
25
|
+
return 'noAction';
|
|
26
|
+
}
|
|
65
27
|
const checkoutId = await fetchCheckoutId();
|
|
66
28
|
if (!checkoutId) {
|
|
67
|
-
return
|
|
29
|
+
return 'noAction';
|
|
68
30
|
}
|
|
69
31
|
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
70
32
|
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;
|
|
71
33
|
if (!(shippingAddress === null || shippingAddress === void 0 ? void 0 : shippingAddress.countryCode)) {
|
|
72
|
-
return
|
|
34
|
+
return 'noAction';
|
|
73
35
|
}
|
|
74
36
|
const countryCode = shippingAddress.countryCode;
|
|
75
37
|
if (!isShippableCountry(false, countryCode)) {
|
|
76
|
-
return
|
|
38
|
+
return 'noAction';
|
|
39
|
+
}
|
|
40
|
+
log(onLoggedInInternationalAddressDetected
|
|
41
|
+
? `Logged-in user has international shipping address: ${countryCode}, prompting user to choose checkout`
|
|
42
|
+
: `Logged-in user has international shipping address: ${countryCode}, redirecting automatically (legacy behavior)`, 'info');
|
|
43
|
+
// Ask the consumer (zonos-checkout) whether to redirect or stay on BC.
|
|
44
|
+
// Without this prompt the user can get stuck in a redirect loop when their
|
|
45
|
+
// saved default address is international but they want to use a different
|
|
46
|
+
// (domestic) saved address in BigCommerce native checkout.
|
|
47
|
+
if (onLoggedInInternationalAddressDetected) {
|
|
48
|
+
const action = await onLoggedInInternationalAddressDetected();
|
|
49
|
+
if (action === 'stay') {
|
|
50
|
+
log('User opted to stay on BigCommerce native checkout despite international default address', 'info');
|
|
51
|
+
return 'optedOut';
|
|
52
|
+
}
|
|
77
53
|
}
|
|
78
|
-
log(`Logged-in user has international shipping address: ${countryCode}, redirecting`, 'info');
|
|
79
54
|
if (onInternationalCheckoutSelected) {
|
|
80
55
|
await onInternationalCheckoutSelected();
|
|
81
56
|
}
|
|
@@ -97,20 +72,24 @@ const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelecte
|
|
|
97
72
|
state: (_k = shippingAddress.stateOrProvince) !== null && _k !== void 0 ? _k : '',
|
|
98
73
|
});
|
|
99
74
|
// Redirect to home page — the home page will open the international checkout
|
|
100
|
-
// when it detects the domestic shipping session
|
|
101
|
-
|
|
102
|
-
|
|
75
|
+
// when it detects the domestic shipping session. Carry over zonosQaUrl /
|
|
76
|
+
// zonosTestMode so the destination page keeps using the same build/env.
|
|
77
|
+
window.location.href = buildBigcommerceRedirectUrl('/');
|
|
78
|
+
return 'redirected';
|
|
103
79
|
};
|
|
104
80
|
/**
|
|
105
81
|
* Watch for changes in domestic checkout step. Redirects user to home page to open international checkout when user selects a country in the international shipping zone.
|
|
106
82
|
* @note Only works on default bigcommerce checkout page
|
|
107
83
|
*/
|
|
108
|
-
export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedBtnSelector, onInternationalCheckoutSelected, onShippingAddressSessionFound, }) => {
|
|
84
|
+
export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedBtnSelector, onInternationalCheckoutSelected, onLoggedInInternationalAddressDetected, onShippingAddressSessionFound, }) => {
|
|
109
85
|
if (!window.Zonos.isBigCommerce) {
|
|
110
86
|
return;
|
|
111
87
|
}
|
|
112
88
|
/**
|
|
113
|
-
* Keep checking
|
|
89
|
+
* Keep checking.
|
|
90
|
+
* @returns `true` if the caller should stop polling — either because the user
|
|
91
|
+
* is being redirected to Zonos international checkout, or because the
|
|
92
|
+
* logged-in customer is in a bypass group and should stay on BC checkout.
|
|
114
93
|
*/
|
|
115
94
|
const handleInternationalCheckoutSelected = async (overrideShippingCountry) => {
|
|
116
95
|
var _a;
|
|
@@ -126,6 +105,19 @@ export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedi
|
|
|
126
105
|
// do nothing if shipping country is not shippable
|
|
127
106
|
return false;
|
|
128
107
|
}
|
|
108
|
+
// Only check bypass after confirming the country is shippable (i.e. user is
|
|
109
|
+
// about to be redirected to Zonos international checkout). Force-refresh so
|
|
110
|
+
// we re-fetch BigCommerce checkout data every time the ship-to country
|
|
111
|
+
// changes — prevents stale customer-group data from a cached fetch.
|
|
112
|
+
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup({
|
|
113
|
+
forceRefresh: true,
|
|
114
|
+
});
|
|
115
|
+
if (shouldBypass) {
|
|
116
|
+
// Logged-in customer is in a bypass group — keep them on BC native
|
|
117
|
+
// checkout and stop polling / fetching further.
|
|
118
|
+
log('Bypass customer group detected on BC checkout, stopping interval', 'info');
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
129
121
|
if (onInternationalCheckoutSelected) {
|
|
130
122
|
await onInternationalCheckoutSelected();
|
|
131
123
|
}
|
|
@@ -157,13 +149,40 @@ export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedi
|
|
|
157
149
|
postalCode: shippingAddress.postalCode,
|
|
158
150
|
state: shippingAddress.stateOrProvince,
|
|
159
151
|
});
|
|
160
|
-
// redirect to home page, home page then will open the checkout dialog if
|
|
161
|
-
|
|
152
|
+
// redirect to home page, home page then will open the checkout dialog if
|
|
153
|
+
// having domestic shipping session. Carry over zonosQaUrl / zonosTestMode
|
|
154
|
+
// so the destination page keeps using the same build/env.
|
|
155
|
+
window.location.href = buildBigcommerceRedirectUrl('/');
|
|
162
156
|
return true;
|
|
163
157
|
};
|
|
164
158
|
let isProcessing = false;
|
|
165
159
|
let intervalCreated = false;
|
|
166
160
|
let isCheckingLoggedInUserShippingAddress = false;
|
|
161
|
+
/**
|
|
162
|
+
* Set to `true` once the logged-in user has been prompted about a detected
|
|
163
|
+
* international default address and chose to stay on the BigCommerce native
|
|
164
|
+
* checkout. Prevents the observer from re-prompting on subsequent DOM
|
|
165
|
+
* mutations.
|
|
166
|
+
*/
|
|
167
|
+
let loggedInAddressCheckSkipped = false;
|
|
168
|
+
/**
|
|
169
|
+
* Set to `true` while the logged-in international-address confirmation
|
|
170
|
+
* dialog is open and we are awaiting the user's response. While this
|
|
171
|
+
* flag is set the polling interval must not call
|
|
172
|
+
* `handleInternationalCheckoutSelected` — otherwise the interval would
|
|
173
|
+
* detect the pre-filled international country, show the loading dialog,
|
|
174
|
+
* and redirect before the user has responded to the confirm prompt.
|
|
175
|
+
*/
|
|
176
|
+
let isAwaitingLoggedInConfirmation = false;
|
|
177
|
+
// NOTE: We intentionally do NOT await `checkBigCommerceBypassCustomerGroup()`
|
|
178
|
+
// here before attaching the MutationObserver. The bypass check involves two
|
|
179
|
+
// Storefront API round-trips, and awaiting it synchronously would delay
|
|
180
|
+
// observer registration — on fast-rendering BC pages that window can cause
|
|
181
|
+
// us to miss the initial DOM mutations and never trigger the redirect.
|
|
182
|
+
// Bypass is already enforced inside `checkLoggedInUserShippingAddress` and
|
|
183
|
+
// `handleInternationalCheckoutSelected` (both consult the helper), so the
|
|
184
|
+
// top-level gate is redundant. `initBigCommerceBypassCheck()` is called on
|
|
185
|
+
// page load so those inner calls typically resolve against a warm cache.
|
|
167
186
|
const observer = new MutationObserver(async () => {
|
|
168
187
|
var _a;
|
|
169
188
|
const domesticRedirectedButton = document.querySelector(domesticRedirectedBtnSelector);
|
|
@@ -190,24 +209,35 @@ export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedi
|
|
|
190
209
|
// For logged-in users, check if their saved address on the checkout is international
|
|
191
210
|
// before the shipping form is even rendered.
|
|
192
211
|
// Guard against repeated calls — the observer fires on every DOM mutation.
|
|
193
|
-
if
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
212
|
+
// Also skip if the user already chose to stay on BC native checkout.
|
|
213
|
+
if (!loggedInAddressCheckSkipped &&
|
|
214
|
+
!isCheckingLoggedInUserShippingAddress) {
|
|
215
|
+
isCheckingLoggedInUserShippingAddress = true;
|
|
216
|
+
isAwaitingLoggedInConfirmation = true;
|
|
217
|
+
try {
|
|
218
|
+
const result = await checkLoggedInUserShippingAddress({
|
|
219
|
+
onInternationalCheckoutSelected,
|
|
220
|
+
onLoggedInInternationalAddressDetected,
|
|
221
|
+
});
|
|
222
|
+
if (result === 'redirected') {
|
|
223
|
+
observer.disconnect();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (result === 'optedOut') {
|
|
227
|
+
// User elected to stay on BC native checkout — don't prompt again
|
|
228
|
+
// for the rest of this session. Continue with the rest of the
|
|
229
|
+
// observer logic so the country-change watcher still fires when
|
|
230
|
+
// the user manually picks an international country in BC's UI.
|
|
231
|
+
loggedInAddressCheckSkipped = true;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
logError('Error checking logged-in user shipping address', error);
|
|
236
|
+
}
|
|
237
|
+
finally {
|
|
238
|
+
isCheckingLoggedInUserShippingAddress = false;
|
|
239
|
+
isAwaitingLoggedInConfirmation = false;
|
|
204
240
|
}
|
|
205
|
-
}
|
|
206
|
-
catch (error) {
|
|
207
|
-
logError('Error checking logged-in user shipping address', error);
|
|
208
|
-
}
|
|
209
|
-
finally {
|
|
210
|
-
isCheckingLoggedInUserShippingAddress = false;
|
|
211
241
|
}
|
|
212
242
|
const shipToCountryElement = document.querySelector(((_a = zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.bigcommerceDomesticCheckoutCountrySelector) ||
|
|
213
243
|
FALLBACK_SHIP_TO_COUNTRY_SELECTOR);
|
|
@@ -227,14 +257,18 @@ export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedi
|
|
|
227
257
|
// disconnect the observer after we know that's bigcommerce domestic checkout page
|
|
228
258
|
observer.disconnect();
|
|
229
259
|
const interval = setInterval(async () => {
|
|
230
|
-
|
|
260
|
+
// Don't redirect while the logged-in international-address confirm
|
|
261
|
+
// dialog is open — the user hasn't made their choice yet.
|
|
262
|
+
if (isProcessing || isAwaitingLoggedInConfirmation) {
|
|
231
263
|
return;
|
|
232
264
|
}
|
|
233
265
|
isProcessing = true;
|
|
234
266
|
try {
|
|
235
|
-
const
|
|
236
|
-
//
|
|
237
|
-
|
|
267
|
+
const shouldStopPolling = await handleInternationalCheckoutSelected();
|
|
268
|
+
// Stop the interval once either:
|
|
269
|
+
// - the user is being redirected to Zonos international checkout
|
|
270
|
+
// - the logged-in customer is in a bypass group (stay on BC checkout)
|
|
271
|
+
if (shouldStopPolling) {
|
|
238
272
|
clearInterval(interval);
|
|
239
273
|
return;
|
|
240
274
|
}
|
|
@@ -258,7 +292,7 @@ export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedi
|
|
|
258
292
|
clearInterval(stripeBcListenerInterval);
|
|
259
293
|
addressElement.on('change', event => {
|
|
260
294
|
const shippingCountry = event.value.address.country;
|
|
261
|
-
if (shippingCountry) {
|
|
295
|
+
if (shippingCountry && !isAwaitingLoggedInConfirmation) {
|
|
262
296
|
void handleInternationalCheckoutSelected(shippingCountry);
|
|
263
297
|
}
|
|
264
298
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as createStore, z as zonosStore } from './zonosStore-5242a58d.js';
|
|
2
|
-
import { s as storageStore, l as localizationStore, e as getOverridenZCountry, t as translate, f as filterValidTests, b as storageStoreSetEnabledVariantTestKeys } from './localization-
|
|
2
|
+
import { s as storageStore, l as localizationStore, e as getOverridenZCountry, t as translate, f as filterValidTests, b as storageStoreSetEnabledVariantTestKeys } from './localization-d11c973f.js';
|
|
3
3
|
import { l as log, b as allLogs } from './VarianceTest-572cecf5.js';
|
|
4
4
|
import { h as handleFetch, l as logError, f as fallbackApiList, g as getIsTestMode, a as getIsStagingMode, s as sendErrorLog, j as jsonParse } from './handleFetch-a844cac1.js';
|
|
5
5
|
import { i as isDarkColor } from './isDarkColor-3537021b.js';
|
package/dist/esm/index.js
CHANGED
|
@@ -131,7 +131,7 @@ const getZonosQaUrl = () => {
|
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
133
133
|
const qaUrl = extractZonosQaUrl(window.location.href);
|
|
134
|
-
const cdnUrl = "https://v1.3.
|
|
134
|
+
const cdnUrl = "https://v1.3.256.js.zonos.com";
|
|
135
135
|
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
136
136
|
if (!qaUrl &&
|
|
137
137
|
(cdnUrl.includes('test.') ||
|
|
@@ -379,10 +379,10 @@ const zonosLoadUrl = (() => {
|
|
|
379
379
|
return null;
|
|
380
380
|
})();
|
|
381
381
|
const startLoadTime = Date.now();
|
|
382
|
-
const ZONOS_URL = "https://v1.3.
|
|
383
|
-
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.
|
|
384
|
-
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.
|
|
385
|
-
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.
|
|
382
|
+
const ZONOS_URL = "https://v1.3.256.js.zonos.com";
|
|
383
|
+
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.256";
|
|
384
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.256";
|
|
385
|
+
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.256";
|
|
386
386
|
const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
|
|
387
387
|
const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
|
|
388
388
|
class Zonos {
|
|
@@ -400,7 +400,7 @@ Zonos.iframeLogType = typeof window !== 'undefined'
|
|
|
400
400
|
? new URLSearchParams(window.location.search).get('iframeLogType')
|
|
401
401
|
: null;
|
|
402
402
|
Zonos.isBigCommerce = false;
|
|
403
|
-
Zonos.releaseDate = "
|
|
403
|
+
Zonos.releaseDate = "1776369543866";
|
|
404
404
|
Zonos.isLegacyCheckout = false;
|
|
405
405
|
Zonos.googleAnalyticId = null;
|
|
406
406
|
Zonos.googleAnalyticReady = false;
|
|
@@ -423,7 +423,7 @@ Zonos.isNpm = true;
|
|
|
423
423
|
Zonos.zonosQaUrl = null;
|
|
424
424
|
Zonos.zonosQaUrlApi = null;
|
|
425
425
|
Zonos.trackEventLogs = [];
|
|
426
|
-
Zonos.version = `v${"1.3.
|
|
426
|
+
Zonos.version = `v${"1.3.256"}`;
|
|
427
427
|
Zonos.modeAlerted = false;
|
|
428
428
|
Zonos.cartData = null;
|
|
429
429
|
Zonos.paypal = null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as createStore, z as zonosStore } from './zonosStore-5242a58d.js';
|
|
2
|
-
import { b as stripeStore, G as stripeStoreBuildAddressForPartyCreate, d as cartStore, H as cartStoreUpdateSelectedShippingOption } from './cart-
|
|
3
|
-
import { s as storageStore } from './localization-
|
|
2
|
+
import { b as stripeStore, G as stripeStoreBuildAddressForPartyCreate, d as cartStore, H as cartStoreUpdateSelectedShippingOption } from './cart-55b8dd7c.js';
|
|
3
|
+
import { s as storageStore } from './localization-d11c973f.js';
|
|
4
4
|
import { h as handleFetch, s as sendErrorLog, l as logError } from './handleFetch-a844cac1.js';
|
|
5
5
|
import { b as allLogs } from './VarianceTest-572cecf5.js';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { c as createStore, z as zonosStore } from './zonosStore-5242a58d.js';
|
|
2
|
-
import { b as stripeStore, G as stripeStoreBuildAddressForPartyCreate, d as cartStore, H as cartStoreUpdateSelectedShippingOption } from './cart-
|
|
3
|
-
import { s as storageStore } from './localization-
|
|
2
|
+
import { b as stripeStore, G as stripeStoreBuildAddressForPartyCreate, d as cartStore, H as cartStoreUpdateSelectedShippingOption } from './cart-55b8dd7c.js';
|
|
3
|
+
import { s as storageStore } from './localization-d11c973f.js';
|
|
4
4
|
import { h as handleFetch, s as sendErrorLog, l as logError } from './handleFetch-a844cac1.js';
|
|
5
5
|
import { b as allLogs } from './VarianceTest-572cecf5.js';
|
|
6
6
|
|