@zonos/elements 1.3.255 → 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-4ef52500.js → cart-e156c1e3.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-4419d03e.js → hasInclusivePrice-d6d274bd.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-3494b21e.js → invoice-f4b5d538.js} +2 -2
- package/dist/cjs/{isCollectMobileTablet-92955ce6.js → isCollectMobileTablet-c9369cd8.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{localization-75f4ec05.js → localization-5bb1e598.js} +240 -0
- package/dist/cjs/{paypal-cc3a730b.js → paypal-f9641595.js} +2 -2
- package/dist/cjs/{placeTestOrder-13901275.js → placeTestOrder-7ac7f91a.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-0003992c.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/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-f4e43d1a.js → cart-55b8dd7c.js} +1 -1
- package/dist/esm/{hasInclusivePrice-0439b7f4.js → hasInclusivePrice-ddae18fd.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-3d8f3fa8.js → invoice-dbe85a18.js} +2 -2
- package/dist/esm/{isCollectMobileTablet-0402aa32.js → isCollectMobileTablet-8af0d16d.js} +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{localization-026da80b.js → localization-d11c973f.js} +240 -0
- package/dist/esm/{paypal-07bd6b7c.js → paypal-f87fbee0.js} +2 -2
- package/dist/esm/{placeTestOrder-39de11f4.js → placeTestOrder-8e8e97be.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-743f7c77.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-f4e43d1a.js → cart-55b8dd7c.js} +1 -1
- package/dist/esm-es5/{hasInclusivePrice-0439b7f4.js → hasInclusivePrice-ddae18fd.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-3d8f3fa8.js → invoice-dbe85a18.js} +1 -1
- package/dist/esm-es5/{isCollectMobileTablet-0402aa32.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-07bd6b7c.js → paypal-f87fbee0.js} +2 -2
- package/dist/esm-es5/{placeTestOrder-39de11f4.js → placeTestOrder-8e8e97be.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-743f7c77.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-5359ba71.entry.js → p-00728af1.entry.js} +1 -1
- package/dist/zonos-elements/{p-b45538a7.system.entry.js → p-08830a50.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1ed9ef0b.js → p-179bbeae.js} +1 -1
- package/dist/zonos-elements/{p-568c5700.system.entry.js → p-1c9e9692.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-231edcca.entry.js → p-225957b9.entry.js} +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/{p-16a80e3c.system.js → p-2a28c7ac.system.js} +1 -1
- package/dist/zonos-elements/{p-12f480c9.system.entry.js → p-2cb5ef7d.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3730d555.system.entry.js → p-2eeda8a9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-66758e30.system.entry.js → p-32365d6a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-db993fdb.entry.js → p-399f5ad6.entry.js} +1 -1
- package/dist/zonos-elements/{p-af83f0c2.js → p-3a8925e9.js} +1 -1
- package/dist/zonos-elements/{p-5e3e5e3e.system.js → p-3f141999.system.js} +1 -1
- package/dist/zonos-elements/{p-dafafa07.js → p-3fae811a.js} +1 -1
- package/dist/zonos-elements/{p-33fc0c8f.entry.js → p-50d31f4f.entry.js} +1 -1
- package/dist/zonos-elements/{p-d397560e.system.entry.js → p-52b70520.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-cc364b26.system.entry.js → p-53275a0d.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-2b10f633.system.js → p-5343c32b.system.js} +1 -1
- package/dist/zonos-elements/{p-0aa1c8c2.system.js → p-57b5d3e3.system.js} +1 -1
- package/dist/zonos-elements/{p-27e41b44.system.entry.js → p-59025df9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3814aac3.system.entry.js → p-5d0b0126.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-5678c5b5.system.entry.js → p-664aff48.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-a1835bae.system.entry.js → p-6b45e9f3.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-50aac43c.system.js → p-70e069d3.system.js} +1 -1
- package/dist/zonos-elements/{p-9e98a256.system.entry.js → p-72de2fdc.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3e03b2e8.entry.js → p-7d4a1565.entry.js} +1 -1
- package/dist/zonos-elements/{p-9d9792b9.system.entry.js → p-8608c123.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1bdac1d3.entry.js → p-89757efe.entry.js} +1 -1
- package/dist/zonos-elements/{p-f888db89.entry.js → p-8a593061.entry.js} +1 -1
- package/dist/zonos-elements/{p-0649737d.entry.js → p-8ccf97ce.entry.js} +1 -1
- package/dist/zonos-elements/{p-835c0bd4.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-d168be79.system.entry.js → p-9b42f0ad.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d938fb86.entry.js → p-aad014df.entry.js} +1 -1
- package/dist/zonos-elements/p-ae397ff8.system.entry.js +1 -0
- package/dist/zonos-elements/{p-9b12f023.system.entry.js → p-b439d38f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e12f7a97.entry.js → p-b85d4286.entry.js} +1 -1
- package/dist/zonos-elements/{p-a6cc56ba.entry.js → p-befad3c4.entry.js} +1 -1
- package/dist/zonos-elements/{p-274a5d11.system.entry.js → p-c66649fe.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-d2bba4dc.entry.js → p-d14e5c81.entry.js} +1 -1
- package/dist/zonos-elements/{p-6ce8374e.entry.js → p-d155b9c6.entry.js} +1 -1
- package/dist/zonos-elements/{p-06b4aa32.system.js → p-d280e9b6.system.js} +1 -1
- package/dist/zonos-elements/{p-fbe22363.entry.js → p-dba635e6.entry.js} +1 -1
- package/dist/zonos-elements/{p-b20c7f8c.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-2affd4e6.entry.js → p-f36e907e.entry.js} +1 -1
- package/dist/zonos-elements/{p-c398711f.js → p-f6733ffb.js} +1 -1
- package/dist/zonos-elements/{p-2baa21b1.entry.js → p-f9ffff4e.entry.js} +1 -1
- package/dist/zonos-elements/p-fa0c5017.js +1 -0
- package/dist/zonos-elements/{p-aabb921f.system.js → p-fbd44c55.system.js} +1 -1
- package/dist/zonos-elements/{p-db0b35a2.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-026da80b.js +0 -1
- package/dist/zonos-elements/p-0d4af7e9.system.entry.js +0 -1
- package/dist/zonos-elements/p-31d1b874.system.js +0 -1
- package/dist/zonos-elements/p-3ac97c01.js +0 -1
- package/dist/zonos-elements/p-768430fe.js +0 -1
- package/dist/zonos-elements/p-b6c78f82.entry.js +0 -1
- package/dist/zonos-elements/p-b84be447.js +0 -1
- package/dist/zonos-elements/p-f9705736.system.js +0 -1
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const paypal = require('./paypal-
|
|
8
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-e156c1e3.js');
|
|
7
|
+
const paypal = require('./paypal-f9641595.js');
|
|
8
|
+
const localization = require('./localization-5bb1e598.js');
|
|
9
9
|
const zonosStore = require('./zonosStore-f5a61112.js');
|
|
10
10
|
const buildCartItemsByTempCart = require('./buildCartItemsByTempCart-edddbf4b.js');
|
|
11
11
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
12
12
|
const updateCheckoutSessionAttributes = require('./updateCheckoutSessionAttributes-8be63b63.js');
|
|
13
|
-
const CheckoutConfig = require('./CheckoutConfig-27c82f94.js');
|
|
14
13
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
14
|
+
const CheckoutConfig = require('./CheckoutConfig-27c82f94.js');
|
|
15
15
|
const classes = require('./classes-b7918f56.js');
|
|
16
16
|
const createCustomEvent = require('./createCustomEvent-7b6fad95.js');
|
|
17
17
|
const getBorderRadius = require('./getBorderRadius-27a74844.js');
|
|
@@ -97,47 +97,28 @@ const buildCartUrl = ({ cartId, checkoutSessionId, customerAddress1, customerAdd
|
|
|
97
97
|
return `${hostedCheckoutUrl}?${urlParams.toString()}`;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
const isDisabledCountry = (showLog = true) => {
|
|
101
|
-
if (!localization.localizationStore.localizationLoaded) {
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
if (localization.localizationStore.isDisabledCountry) {
|
|
105
|
-
if (showLog) {
|
|
106
|
-
VarianceTest.log(`Checkout: disabled country`);
|
|
107
|
-
}
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
return false;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const isShippableCountry = (showLog = true,
|
|
114
100
|
/**
|
|
115
|
-
*
|
|
101
|
+
* Build an absolute redirect URL used by the BigCommerce checkout flows to
|
|
102
|
+
* navigate between the BC native `/checkout` page and the Zonos international
|
|
103
|
+
* checkout at `/`.
|
|
104
|
+
*
|
|
105
|
+
* Carries over the `zonosQaUrl` query param from the current URL (when
|
|
106
|
+
* present) so the preview Zonos elements build keeps loading after the
|
|
107
|
+
* redirect, and sets `zonosTestMode=1` when test mode is active so the
|
|
108
|
+
* destination page continues to use the test credentials.
|
|
116
109
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
if (providedCountryCode) {
|
|
123
|
-
const isProvidedCountryCodeShippableCountry = !!((_a = localization.localizationStore.shippingZoneCountries) === null || _a === void 0 ? void 0 : _a[providedCountryCode]) &&
|
|
124
|
-
!zonosStore.zonosStore.disabledCountries.includes(providedCountryCode);
|
|
125
|
-
if (showLog && !isProvidedCountryCodeShippableCountry) {
|
|
126
|
-
VarianceTest.log(`Checkout: ${providedCountryCode} is not a shippable country: ${isProvidedCountryCodeShippableCountry}`);
|
|
127
|
-
}
|
|
128
|
-
return isProvidedCountryCodeShippableCountry;
|
|
110
|
+
const buildBigcommerceRedirectUrl = (pathname) => {
|
|
111
|
+
const url = new URL(pathname, window.location.origin);
|
|
112
|
+
const zonosQaUrl = new URLSearchParams(window.location.search).get('zonosQaUrl');
|
|
113
|
+
if (zonosQaUrl) {
|
|
114
|
+
url.searchParams.set('zonosQaUrl', zonosQaUrl);
|
|
129
115
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
if (showLog) {
|
|
133
|
-
VarianceTest.log(`Checkout: not shippable country`);
|
|
134
|
-
}
|
|
135
|
-
return false;
|
|
116
|
+
if (handleFetch.getIsTestMode()) {
|
|
117
|
+
url.searchParams.set('zonosTestMode', '1');
|
|
136
118
|
}
|
|
137
|
-
return
|
|
119
|
+
return url.toString();
|
|
138
120
|
};
|
|
139
121
|
|
|
140
|
-
const FALLBACK_SHIP_TO_COUNTRY_SELECTOR = 'select[name="shippingAddress.countryCode"]';
|
|
141
122
|
/**
|
|
142
123
|
* Fetch the checkout/cart ID from the BigCommerce Storefront Cart API.
|
|
143
124
|
* The `/checkout` page URL does not include the checkout ID, so we
|
|
@@ -170,7 +151,7 @@ const fetchCheckoutId = async () => {
|
|
|
170
151
|
*/
|
|
171
152
|
const fetchBigCommerceCheckout = async (checkoutId) => {
|
|
172
153
|
try {
|
|
173
|
-
const response = await fetch(`/api/storefront/checkouts/${checkoutId}`, {
|
|
154
|
+
const response = await fetch(`/api/storefront/checkouts/${checkoutId}?include=customer.customerGroup`, {
|
|
174
155
|
credentials: 'same-origin',
|
|
175
156
|
headers: {
|
|
176
157
|
Accept: 'application/json',
|
|
@@ -188,27 +169,211 @@ const fetchBigCommerceCheckout = async (checkoutId) => {
|
|
|
188
169
|
return null;
|
|
189
170
|
}
|
|
190
171
|
};
|
|
172
|
+
|
|
173
|
+
const DEFAULT_RESULT = {
|
|
174
|
+
customerGroupId: null,
|
|
175
|
+
shouldBypass: false,
|
|
176
|
+
};
|
|
177
|
+
/**
|
|
178
|
+
* Performs the actual fetch logic to determine if the customer
|
|
179
|
+
* belongs to a bypass group.
|
|
180
|
+
*/
|
|
181
|
+
const fetchBypassOutcome = async () => {
|
|
182
|
+
var _a, _b, _c, _d;
|
|
183
|
+
// Only relevant for BigCommerce stores — permanent no-op on other platforms
|
|
184
|
+
if (!window.Zonos.isBigCommerce) {
|
|
185
|
+
return { conclusive: true, result: DEFAULT_RESULT };
|
|
186
|
+
}
|
|
187
|
+
const bypassGroupIds = (_a = zonosStore.zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.bigcommerceBypassCustomerGroupIds;
|
|
188
|
+
if (!(bypassGroupIds === null || bypassGroupIds === void 0 ? void 0 : bypassGroupIds.length)) {
|
|
189
|
+
if (zonosStore.zonosStore.loadedConfig) {
|
|
190
|
+
// Settings have finished loading and there are no bypass groups
|
|
191
|
+
// configured — this is a permanent "bypass not configured" answer.
|
|
192
|
+
return { conclusive: true, result: DEFAULT_RESULT };
|
|
193
|
+
}
|
|
194
|
+
// Settings haven't loaded yet — the empty list may be transient.
|
|
195
|
+
// Mark as inconclusive so a later caller retries after config loads.
|
|
196
|
+
return { conclusive: false, result: DEFAULT_RESULT };
|
|
197
|
+
}
|
|
198
|
+
// Fetch customer group from BigCommerce Storefront API
|
|
199
|
+
const checkoutId = await fetchCheckoutId();
|
|
200
|
+
if (!checkoutId) {
|
|
201
|
+
// No active cart yet — inconclusive. Common on fresh sessions where
|
|
202
|
+
// `initBigCommerceBypassCheck` runs before the user has added anything
|
|
203
|
+
// to their cart; once the cart exists we need to re-fetch.
|
|
204
|
+
VarianceTest.log('BigCommerce bypass check: no active cart yet, will retry on next call', 'info');
|
|
205
|
+
return { conclusive: false, result: DEFAULT_RESULT };
|
|
206
|
+
}
|
|
207
|
+
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
208
|
+
if (!checkout) {
|
|
209
|
+
// API call failed (network error, non-200, etc.) — inconclusive.
|
|
210
|
+
// Caching this would permanently disable bypass for the session if
|
|
211
|
+
// the logged-in user is actually a reseller.
|
|
212
|
+
VarianceTest.log('BigCommerce bypass check: failed to fetch checkout data, will retry', 'info');
|
|
213
|
+
return { conclusive: false, result: DEFAULT_RESULT };
|
|
214
|
+
}
|
|
215
|
+
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;
|
|
216
|
+
if (customerGroupId === null) {
|
|
217
|
+
VarianceTest.log('BigCommerce bypass check: no customer group found (guest user)', 'info');
|
|
218
|
+
// Guest user with an active cart — a definitive "no bypass" answer.
|
|
219
|
+
return { conclusive: true, result: DEFAULT_RESULT };
|
|
220
|
+
}
|
|
221
|
+
const shouldBypass = bypassGroupIds.includes(customerGroupId);
|
|
222
|
+
const result = { customerGroupId, shouldBypass };
|
|
223
|
+
if (shouldBypass) {
|
|
224
|
+
VarianceTest.log(`BigCommerce bypass check: customer group ${String(customerGroupId)} is in bypass list; caller should keep the user on BC native checkout`, 'info');
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
VarianceTest.log(`BigCommerce bypass check: customer group ${String(customerGroupId)} is not in bypass list`, 'info');
|
|
228
|
+
}
|
|
229
|
+
return { conclusive: true, result };
|
|
230
|
+
};
|
|
231
|
+
/**
|
|
232
|
+
* Module-level promise that holds the in-flight or resolved bypass check.
|
|
233
|
+
* Set by `initBigCommerceBypassCheck` on page load so the result is ready
|
|
234
|
+
* by the time checkout opens or the watcher fires.
|
|
235
|
+
*
|
|
236
|
+
* Automatically invalidated when a fetch resolves to an inconclusive outcome,
|
|
237
|
+
* so subsequent callers retry (e.g. after the user adds an item to their
|
|
238
|
+
* cart or after settings finish loading).
|
|
239
|
+
*/
|
|
240
|
+
let bypassCheckPromise = null;
|
|
241
|
+
const startBypassCheck = () => {
|
|
242
|
+
const outcomePromise = fetchBypassOutcome();
|
|
243
|
+
const resultPromise = outcomePromise.then(({ conclusive, result }) => {
|
|
244
|
+
if (!conclusive && bypassCheckPromise === resultPromise) {
|
|
245
|
+
// Invalidate cache so the next caller performs a fresh fetch.
|
|
246
|
+
bypassCheckPromise = null;
|
|
247
|
+
}
|
|
248
|
+
return result;
|
|
249
|
+
});
|
|
250
|
+
bypassCheckPromise = resultPromise;
|
|
251
|
+
return resultPromise;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Start fetching the BigCommerce customer group on page load.
|
|
255
|
+
* Call this once during initialization (e.g. in `zonos-checkout.init()`).
|
|
256
|
+
* The fetch runs in the background; `checkBigCommerceBypassCustomerGroup`
|
|
257
|
+
* will await the result when needed.
|
|
258
|
+
*/
|
|
259
|
+
const initBigCommerceBypassCheck = () => {
|
|
260
|
+
var _a;
|
|
261
|
+
if (!window.Zonos.isBigCommerce) {
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const bypassGroupIds = (_a = zonosStore.zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.bigcommerceBypassCustomerGroupIds;
|
|
265
|
+
if (!(bypassGroupIds === null || bypassGroupIds === void 0 ? void 0 : bypassGroupIds.length)) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
// Fire the fetch immediately; consumers will await the same promise
|
|
269
|
+
void startBypassCheck();
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* Check if the current BigCommerce customer belongs to a customer group
|
|
273
|
+
* that should bypass Zonos Checkout.
|
|
274
|
+
*
|
|
275
|
+
* If `initBigCommerceBypassCheck` was called on page load and the resulting
|
|
276
|
+
* outcome was conclusive, this returns the already-resolved (or in-flight)
|
|
277
|
+
* result without making additional API calls. If the previous outcome was
|
|
278
|
+
* inconclusive (no cart, settings not loaded), the cache was invalidated
|
|
279
|
+
* automatically and this triggers a fresh fetch.
|
|
280
|
+
*
|
|
281
|
+
* @param options.forceRefresh - When true, bypasses any cached result and
|
|
282
|
+
* always fetches fresh BigCommerce checkout data. Use this on the
|
|
283
|
+
* BigCommerce domestic checkout page when the shipping country changes,
|
|
284
|
+
* to ensure the customer group reflects the current checkout state.
|
|
285
|
+
*/
|
|
286
|
+
const checkBigCommerceBypassCustomerGroup = async (options = {}) => {
|
|
287
|
+
if (options.forceRefresh || !bypassCheckPromise) {
|
|
288
|
+
return startBypassCheck();
|
|
289
|
+
}
|
|
290
|
+
return bypassCheckPromise;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
const isDisabledCountry = (showLog = true) => {
|
|
294
|
+
if (!localization.localizationStore.localizationLoaded) {
|
|
295
|
+
return true;
|
|
296
|
+
}
|
|
297
|
+
if (localization.localizationStore.isDisabledCountry) {
|
|
298
|
+
if (showLog) {
|
|
299
|
+
VarianceTest.log(`Checkout: disabled country`);
|
|
300
|
+
}
|
|
301
|
+
return true;
|
|
302
|
+
}
|
|
303
|
+
return false;
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
const isShippableCountry = (showLog = true,
|
|
307
|
+
/**
|
|
308
|
+
* If provided, will check if the country is shippable based on the provided country code instead of the Hello selected country code
|
|
309
|
+
*/
|
|
310
|
+
providedCountryCode) => {
|
|
311
|
+
var _a;
|
|
312
|
+
if (!localization.localizationStore.localizationLoaded) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
if (providedCountryCode) {
|
|
316
|
+
const isProvidedCountryCodeShippableCountry = !!((_a = localization.localizationStore.shippingZoneCountries) === null || _a === void 0 ? void 0 : _a[providedCountryCode]) &&
|
|
317
|
+
!zonosStore.zonosStore.disabledCountries.includes(providedCountryCode);
|
|
318
|
+
if (showLog && !isProvidedCountryCodeShippableCountry) {
|
|
319
|
+
VarianceTest.log(`Checkout: ${providedCountryCode} is not a shippable country: ${isProvidedCountryCodeShippableCountry}`);
|
|
320
|
+
}
|
|
321
|
+
return isProvidedCountryCodeShippableCountry;
|
|
322
|
+
}
|
|
323
|
+
// if localization is loaded and the localization is not a shippable country, keep the original click event
|
|
324
|
+
if (!localization.localizationStore.isShippableCountry) {
|
|
325
|
+
if (showLog) {
|
|
326
|
+
VarianceTest.log(`Checkout: not shippable country`);
|
|
327
|
+
}
|
|
328
|
+
return false;
|
|
329
|
+
}
|
|
330
|
+
return true;
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
const FALLBACK_SHIP_TO_COUNTRY_SELECTOR = 'select[name="shippingAddress.countryCode"]';
|
|
191
334
|
/**
|
|
192
335
|
* Check if the logged-in user already has a shipping address on the checkout
|
|
193
|
-
* that is internationally shippable. If so,
|
|
194
|
-
*
|
|
336
|
+
* that is internationally shippable. If so, optionally prompt the user to
|
|
337
|
+
* confirm before saving the address to session and redirecting to the home
|
|
338
|
+
* page to open the international checkout.
|
|
195
339
|
*/
|
|
196
|
-
const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelected, }) => {
|
|
340
|
+
const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelected, onLoggedInInternationalAddressDetected, }) => {
|
|
197
341
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
342
|
+
// Check if the customer belongs to a bypass group (e.g. resellers) before
|
|
343
|
+
// redirecting them away from BigCommerce native checkout. This delegates to
|
|
344
|
+
// the shared helper so the bypass decision has a single source of truth and
|
|
345
|
+
// reuses the cached promise warmed by `initBigCommerceBypassCheck`.
|
|
346
|
+
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup();
|
|
347
|
+
if (shouldBypass) {
|
|
348
|
+
return 'noAction';
|
|
349
|
+
}
|
|
198
350
|
const checkoutId = await fetchCheckoutId();
|
|
199
351
|
if (!checkoutId) {
|
|
200
|
-
return
|
|
352
|
+
return 'noAction';
|
|
201
353
|
}
|
|
202
354
|
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
203
355
|
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;
|
|
204
356
|
if (!(shippingAddress === null || shippingAddress === void 0 ? void 0 : shippingAddress.countryCode)) {
|
|
205
|
-
return
|
|
357
|
+
return 'noAction';
|
|
206
358
|
}
|
|
207
359
|
const countryCode = shippingAddress.countryCode;
|
|
208
360
|
if (!isShippableCountry(false, countryCode)) {
|
|
209
|
-
return
|
|
361
|
+
return 'noAction';
|
|
362
|
+
}
|
|
363
|
+
VarianceTest.log(onLoggedInInternationalAddressDetected
|
|
364
|
+
? `Logged-in user has international shipping address: ${countryCode}, prompting user to choose checkout`
|
|
365
|
+
: `Logged-in user has international shipping address: ${countryCode}, redirecting automatically (legacy behavior)`, 'info');
|
|
366
|
+
// Ask the consumer (zonos-checkout) whether to redirect or stay on BC.
|
|
367
|
+
// Without this prompt the user can get stuck in a redirect loop when their
|
|
368
|
+
// saved default address is international but they want to use a different
|
|
369
|
+
// (domestic) saved address in BigCommerce native checkout.
|
|
370
|
+
if (onLoggedInInternationalAddressDetected) {
|
|
371
|
+
const action = await onLoggedInInternationalAddressDetected();
|
|
372
|
+
if (action === 'stay') {
|
|
373
|
+
VarianceTest.log('User opted to stay on BigCommerce native checkout despite international default address', 'info');
|
|
374
|
+
return 'optedOut';
|
|
375
|
+
}
|
|
210
376
|
}
|
|
211
|
-
VarianceTest.log(`Logged-in user has international shipping address: ${countryCode}, redirecting`, 'info');
|
|
212
377
|
if (onInternationalCheckoutSelected) {
|
|
213
378
|
await onInternationalCheckoutSelected();
|
|
214
379
|
}
|
|
@@ -230,20 +395,24 @@ const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelecte
|
|
|
230
395
|
state: (_k = shippingAddress.stateOrProvince) !== null && _k !== void 0 ? _k : '',
|
|
231
396
|
});
|
|
232
397
|
// Redirect to home page — the home page will open the international checkout
|
|
233
|
-
// when it detects the domestic shipping session
|
|
234
|
-
|
|
235
|
-
|
|
398
|
+
// when it detects the domestic shipping session. Carry over zonosQaUrl /
|
|
399
|
+
// zonosTestMode so the destination page keeps using the same build/env.
|
|
400
|
+
window.location.href = buildBigcommerceRedirectUrl('/');
|
|
401
|
+
return 'redirected';
|
|
236
402
|
};
|
|
237
403
|
/**
|
|
238
404
|
* 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.
|
|
239
405
|
* @note Only works on default bigcommerce checkout page
|
|
240
406
|
*/
|
|
241
|
-
const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedBtnSelector, onInternationalCheckoutSelected, onShippingAddressSessionFound, }) => {
|
|
407
|
+
const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedBtnSelector, onInternationalCheckoutSelected, onLoggedInInternationalAddressDetected, onShippingAddressSessionFound, }) => {
|
|
242
408
|
if (!window.Zonos.isBigCommerce) {
|
|
243
409
|
return;
|
|
244
410
|
}
|
|
245
411
|
/**
|
|
246
|
-
* Keep checking
|
|
412
|
+
* Keep checking.
|
|
413
|
+
* @returns `true` if the caller should stop polling — either because the user
|
|
414
|
+
* is being redirected to Zonos international checkout, or because the
|
|
415
|
+
* logged-in customer is in a bypass group and should stay on BC checkout.
|
|
247
416
|
*/
|
|
248
417
|
const handleInternationalCheckoutSelected = async (overrideShippingCountry) => {
|
|
249
418
|
var _a;
|
|
@@ -259,6 +428,19 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
|
|
|
259
428
|
// do nothing if shipping country is not shippable
|
|
260
429
|
return false;
|
|
261
430
|
}
|
|
431
|
+
// Only check bypass after confirming the country is shippable (i.e. user is
|
|
432
|
+
// about to be redirected to Zonos international checkout). Force-refresh so
|
|
433
|
+
// we re-fetch BigCommerce checkout data every time the ship-to country
|
|
434
|
+
// changes — prevents stale customer-group data from a cached fetch.
|
|
435
|
+
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup({
|
|
436
|
+
forceRefresh: true,
|
|
437
|
+
});
|
|
438
|
+
if (shouldBypass) {
|
|
439
|
+
// Logged-in customer is in a bypass group — keep them on BC native
|
|
440
|
+
// checkout and stop polling / fetching further.
|
|
441
|
+
VarianceTest.log('Bypass customer group detected on BC checkout, stopping interval', 'info');
|
|
442
|
+
return true;
|
|
443
|
+
}
|
|
262
444
|
if (onInternationalCheckoutSelected) {
|
|
263
445
|
await onInternationalCheckoutSelected();
|
|
264
446
|
}
|
|
@@ -290,13 +472,40 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
|
|
|
290
472
|
postalCode: shippingAddress.postalCode,
|
|
291
473
|
state: shippingAddress.stateOrProvince,
|
|
292
474
|
});
|
|
293
|
-
// redirect to home page, home page then will open the checkout dialog if
|
|
294
|
-
|
|
475
|
+
// redirect to home page, home page then will open the checkout dialog if
|
|
476
|
+
// having domestic shipping session. Carry over zonosQaUrl / zonosTestMode
|
|
477
|
+
// so the destination page keeps using the same build/env.
|
|
478
|
+
window.location.href = buildBigcommerceRedirectUrl('/');
|
|
295
479
|
return true;
|
|
296
480
|
};
|
|
297
481
|
let isProcessing = false;
|
|
298
482
|
let intervalCreated = false;
|
|
299
483
|
let isCheckingLoggedInUserShippingAddress = false;
|
|
484
|
+
/**
|
|
485
|
+
* Set to `true` once the logged-in user has been prompted about a detected
|
|
486
|
+
* international default address and chose to stay on the BigCommerce native
|
|
487
|
+
* checkout. Prevents the observer from re-prompting on subsequent DOM
|
|
488
|
+
* mutations.
|
|
489
|
+
*/
|
|
490
|
+
let loggedInAddressCheckSkipped = false;
|
|
491
|
+
/**
|
|
492
|
+
* Set to `true` while the logged-in international-address confirmation
|
|
493
|
+
* dialog is open and we are awaiting the user's response. While this
|
|
494
|
+
* flag is set the polling interval must not call
|
|
495
|
+
* `handleInternationalCheckoutSelected` — otherwise the interval would
|
|
496
|
+
* detect the pre-filled international country, show the loading dialog,
|
|
497
|
+
* and redirect before the user has responded to the confirm prompt.
|
|
498
|
+
*/
|
|
499
|
+
let isAwaitingLoggedInConfirmation = false;
|
|
500
|
+
// NOTE: We intentionally do NOT await `checkBigCommerceBypassCustomerGroup()`
|
|
501
|
+
// here before attaching the MutationObserver. The bypass check involves two
|
|
502
|
+
// Storefront API round-trips, and awaiting it synchronously would delay
|
|
503
|
+
// observer registration — on fast-rendering BC pages that window can cause
|
|
504
|
+
// us to miss the initial DOM mutations and never trigger the redirect.
|
|
505
|
+
// Bypass is already enforced inside `checkLoggedInUserShippingAddress` and
|
|
506
|
+
// `handleInternationalCheckoutSelected` (both consult the helper), so the
|
|
507
|
+
// top-level gate is redundant. `initBigCommerceBypassCheck()` is called on
|
|
508
|
+
// page load so those inner calls typically resolve against a warm cache.
|
|
300
509
|
const observer = new MutationObserver(async () => {
|
|
301
510
|
var _a;
|
|
302
511
|
const domesticRedirectedButton = document.querySelector(domesticRedirectedBtnSelector);
|
|
@@ -323,24 +532,35 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
|
|
|
323
532
|
// For logged-in users, check if their saved address on the checkout is international
|
|
324
533
|
// before the shipping form is even rendered.
|
|
325
534
|
// Guard against repeated calls — the observer fires on every DOM mutation.
|
|
326
|
-
if
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
535
|
+
// Also skip if the user already chose to stay on BC native checkout.
|
|
536
|
+
if (!loggedInAddressCheckSkipped &&
|
|
537
|
+
!isCheckingLoggedInUserShippingAddress) {
|
|
538
|
+
isCheckingLoggedInUserShippingAddress = true;
|
|
539
|
+
isAwaitingLoggedInConfirmation = true;
|
|
540
|
+
try {
|
|
541
|
+
const result = await checkLoggedInUserShippingAddress({
|
|
542
|
+
onInternationalCheckoutSelected,
|
|
543
|
+
onLoggedInInternationalAddressDetected,
|
|
544
|
+
});
|
|
545
|
+
if (result === 'redirected') {
|
|
546
|
+
observer.disconnect();
|
|
547
|
+
return;
|
|
548
|
+
}
|
|
549
|
+
if (result === 'optedOut') {
|
|
550
|
+
// User elected to stay on BC native checkout — don't prompt again
|
|
551
|
+
// for the rest of this session. Continue with the rest of the
|
|
552
|
+
// observer logic so the country-change watcher still fires when
|
|
553
|
+
// the user manually picks an international country in BC's UI.
|
|
554
|
+
loggedInAddressCheckSkipped = true;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
catch (error) {
|
|
558
|
+
handleFetch.logError('Error checking logged-in user shipping address', error);
|
|
559
|
+
}
|
|
560
|
+
finally {
|
|
561
|
+
isCheckingLoggedInUserShippingAddress = false;
|
|
562
|
+
isAwaitingLoggedInConfirmation = false;
|
|
337
563
|
}
|
|
338
|
-
}
|
|
339
|
-
catch (error) {
|
|
340
|
-
handleFetch.logError('Error checking logged-in user shipping address', error);
|
|
341
|
-
}
|
|
342
|
-
finally {
|
|
343
|
-
isCheckingLoggedInUserShippingAddress = false;
|
|
344
564
|
}
|
|
345
565
|
const shipToCountryElement = document.querySelector(((_a = zonosStore.zonosStore.genericSettings) === null || _a === void 0 ? void 0 : _a.bigcommerceDomesticCheckoutCountrySelector) ||
|
|
346
566
|
FALLBACK_SHIP_TO_COUNTRY_SELECTOR);
|
|
@@ -360,14 +580,18 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
|
|
|
360
580
|
// disconnect the observer after we know that's bigcommerce domestic checkout page
|
|
361
581
|
observer.disconnect();
|
|
362
582
|
const interval = setInterval(async () => {
|
|
363
|
-
|
|
583
|
+
// Don't redirect while the logged-in international-address confirm
|
|
584
|
+
// dialog is open — the user hasn't made their choice yet.
|
|
585
|
+
if (isProcessing || isAwaitingLoggedInConfirmation) {
|
|
364
586
|
return;
|
|
365
587
|
}
|
|
366
588
|
isProcessing = true;
|
|
367
589
|
try {
|
|
368
|
-
const
|
|
369
|
-
//
|
|
370
|
-
|
|
590
|
+
const shouldStopPolling = await handleInternationalCheckoutSelected();
|
|
591
|
+
// Stop the interval once either:
|
|
592
|
+
// - the user is being redirected to Zonos international checkout
|
|
593
|
+
// - the logged-in customer is in a bypass group (stay on BC checkout)
|
|
594
|
+
if (shouldStopPolling) {
|
|
371
595
|
clearInterval(interval);
|
|
372
596
|
return;
|
|
373
597
|
}
|
|
@@ -391,7 +615,7 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
|
|
|
391
615
|
clearInterval(stripeBcListenerInterval);
|
|
392
616
|
addressElement.on('change', event => {
|
|
393
617
|
const shippingCountry = event.value.address.country;
|
|
394
|
-
if (shippingCountry) {
|
|
618
|
+
if (shippingCountry && !isAwaitingLoggedInConfirmation) {
|
|
395
619
|
void handleInternationalCheckoutSelected(shippingCountry);
|
|
396
620
|
}
|
|
397
621
|
});
|
|
@@ -699,6 +923,19 @@ const ZonosCheckout = class {
|
|
|
699
923
|
* This is for BigCommerce stores when the user selects a domestic country in the international checkout.
|
|
700
924
|
*/
|
|
701
925
|
this.redirectToDomesticCheckoutDialogOpen = false;
|
|
926
|
+
/**
|
|
927
|
+
* Whether or not the confirm dialog for a logged-in BigCommerce user with a
|
|
928
|
+
* detected international default shipping address is shown. The user must
|
|
929
|
+
* choose to either continue to the international checkout or stay on the
|
|
930
|
+
* BigCommerce native checkout (and select a domestic address there).
|
|
931
|
+
*/
|
|
932
|
+
this.loggedInIntlAddressConfirmDialogOpen = false;
|
|
933
|
+
/**
|
|
934
|
+
* Resolver for the promise returned to
|
|
935
|
+
* `watchImmediateBigcommerceDomesticCheckoutRedirect` while we wait for
|
|
936
|
+
* the user's choice in `loggedInIntlAddressConfirmDialogOpen`.
|
|
937
|
+
*/
|
|
938
|
+
this.loggedInIntlAddressResolver = null;
|
|
702
939
|
/**
|
|
703
940
|
* Client secret value
|
|
704
941
|
*/
|
|
@@ -1311,6 +1548,23 @@ const ZonosCheckout = class {
|
|
|
1311
1548
|
return;
|
|
1312
1549
|
}
|
|
1313
1550
|
}
|
|
1551
|
+
// For BigCommerce stores: check if the customer belongs to a bypass
|
|
1552
|
+
// group (e.g. resellers) and redirect them to BigCommerce native
|
|
1553
|
+
// checkout instead. This must happen *before* we flip any UI state
|
|
1554
|
+
// (opening the dialog, setting the fetching-session flag) so bypass
|
|
1555
|
+
// users never see the Zonos checkout dialog flash.
|
|
1556
|
+
// `initBigCommerceBypassCheck` was called on page load so this
|
|
1557
|
+
// typically resolves against the cached promise.
|
|
1558
|
+
if (window.Zonos.isBigCommerce) {
|
|
1559
|
+
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup();
|
|
1560
|
+
if (shouldBypass) {
|
|
1561
|
+
VarianceTest.log('Bypass customer group detected, redirecting to BigCommerce native checkout', 'info');
|
|
1562
|
+
// Carry over zonosQaUrl / zonosTestMode so the BC native
|
|
1563
|
+
// checkout keeps loading the same Zonos elements build/env.
|
|
1564
|
+
window.location.href = buildBigcommerceRedirectUrl('/checkout');
|
|
1565
|
+
return;
|
|
1566
|
+
}
|
|
1567
|
+
}
|
|
1314
1568
|
// start loading
|
|
1315
1569
|
cart.stripeStore.isFetchingSession = true;
|
|
1316
1570
|
this.open = true;
|
|
@@ -1559,6 +1813,9 @@ const ZonosCheckout = class {
|
|
|
1559
1813
|
if (typeof this.overrideStagingMode !== 'undefined') {
|
|
1560
1814
|
cart.cartStore.isStagingMode = this.overrideStagingMode;
|
|
1561
1815
|
}
|
|
1816
|
+
// Start fetching BigCommerce customer group on page load so the bypass
|
|
1817
|
+
// result is ready by the time checkout opens or the BC watcher fires
|
|
1818
|
+
initBigCommerceBypassCheck();
|
|
1562
1819
|
// check if bigcommerce, if user enters the shipping address that's in the shipping zone at bigcommerce checkout
|
|
1563
1820
|
watchImmediateBigcommerceDomesticCheckoutRedirect({
|
|
1564
1821
|
domesticRedirectedBtnSelector: CheckoutConfig.domesticRedirectedBtnSelector,
|
|
@@ -1567,6 +1824,16 @@ const ZonosCheckout = class {
|
|
|
1567
1824
|
// wait for 2 secs
|
|
1568
1825
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
1569
1826
|
},
|
|
1827
|
+
// Logged-in user is on the BC native /checkout page with a saved
|
|
1828
|
+
// international default address. Ask the user whether to continue to
|
|
1829
|
+
// the Zonos international checkout or stay on BC and pick a different
|
|
1830
|
+
// (domestic) saved address. This avoids the redirect loop where a user
|
|
1831
|
+
// who wants to checkout domestically gets bounced back to international
|
|
1832
|
+
// every time they land on /checkout.
|
|
1833
|
+
onLoggedInInternationalAddressDetected: () => new Promise(resolve => {
|
|
1834
|
+
this.loggedInIntlAddressResolver = resolve;
|
|
1835
|
+
this.loggedInIntlAddressConfirmDialogOpen = true;
|
|
1836
|
+
}),
|
|
1570
1837
|
onShippingAddressSessionFound: shippingAddressSession => {
|
|
1571
1838
|
// prefilled the default address if shipping address session is found for checkout on open
|
|
1572
1839
|
this.defaultAddress = [
|
|
@@ -2056,7 +2323,9 @@ const ZonosCheckout = class {
|
|
|
2056
2323
|
this.redirectToDomesticCheckoutDialogOpen = true;
|
|
2057
2324
|
VarianceTest.log(`Domestic country ${shippingCountry} selected in international checkout, redirecting to BigCommerce domestic checkout`, 'info');
|
|
2058
2325
|
setTimeout(() => {
|
|
2059
|
-
|
|
2326
|
+
// Carry over zonosQaUrl / zonosTestMode so the BC native checkout
|
|
2327
|
+
// keeps loading the same Zonos elements build/env.
|
|
2328
|
+
window.location.href = buildBigcommerceRedirectUrl('/checkout');
|
|
2060
2329
|
}, 2000);
|
|
2061
2330
|
}
|
|
2062
2331
|
}),
|
|
@@ -2167,7 +2436,17 @@ const ZonosCheckout = class {
|
|
|
2167
2436
|
this.isMobile && 'mobile',
|
|
2168
2437
|
this.isIframed && 'iframed',
|
|
2169
2438
|
this.hiddenMode && 'hidden-mode',
|
|
2170
|
-
]) }, this.preview ? (renderContent()) : (index.h("zonos-dialog", { borderStyle: style, class: "zonos--checkout-dialog", "data-theme": rightSideTheme, height: "980px", isLoading: dialogLoading, mobile: this.isMobile, noBodyPadding: true, noBorder: true, noClickOutside: true, noCloseButton: true, onCloseDialog: () => this.closeDialogHandler(), open: this.open, width: "1200px" }, renderContent())), index.h("zonos-dialog", { isLoading: true, loadingText: localization.translate('You will be redirected to international checkout shortly.'), loadingTitle: localization.translate('We detected that you are shipping to an international address.'), noClickOutside: true, noCloseButton: true, open: this.detectedDomesticCheckoutDialogOpen, width: "450px" }), index.h("zonos-dialog", { isLoading: true, loadingText: localization.translate('You will be redirected to domestic checkout shortly.'), loadingTitle: localization.translate('We detected that you are shipping to a domestic address.'), noClickOutside: true, noCloseButton: true, open: this.redirectToDomesticCheckoutDialogOpen, width: "450px" }), index.h("zonos-confirm-dialog", { class: "zonos--
|
|
2439
|
+
]) }, this.preview ? (renderContent()) : (index.h("zonos-dialog", { borderStyle: style, class: "zonos--checkout-dialog", "data-theme": rightSideTheme, height: "980px", isLoading: dialogLoading, mobile: this.isMobile, noBodyPadding: true, noBorder: true, noClickOutside: true, noCloseButton: true, onCloseDialog: () => this.closeDialogHandler(), open: this.open, width: "1200px" }, renderContent())), index.h("zonos-dialog", { isLoading: true, loadingText: localization.translate('You will be redirected to international checkout shortly.'), loadingTitle: localization.translate('We detected that you are shipping to an international address.'), noClickOutside: true, noCloseButton: true, open: this.detectedDomesticCheckoutDialogOpen, width: "450px" }), index.h("zonos-dialog", { isLoading: true, loadingText: localization.translate('You will be redirected to domestic checkout shortly.'), loadingTitle: localization.translate('We detected that you are shipping to a domestic address.'), noClickOutside: true, noCloseButton: true, open: this.redirectToDomesticCheckoutDialogOpen, width: "450px" }), index.h("zonos-confirm-dialog", { class: "zonos--logged-in-intl-address-dialog", dialogCancelBtnText: localization.translate('Stay on this page'), dialogConfirmBtnText: localization.translate('Continue to international checkout'), dialogIntent: "info", dialogOpen: this.loggedInIntlAddressConfirmDialogOpen, dialogSubtitle: localization.translate('Your saved default address ships internationally. Would you like to continue to international checkout, or stay here and select a domestic address?'), dialogTitle: localization.translate('International shipping address detected'), dialogWidth: 480, onCancelClicked: () => {
|
|
2440
|
+
var _a;
|
|
2441
|
+
this.loggedInIntlAddressConfirmDialogOpen = false;
|
|
2442
|
+
(_a = this.loggedInIntlAddressResolver) === null || _a === void 0 ? void 0 : _a.call(this, 'stay');
|
|
2443
|
+
this.loggedInIntlAddressResolver = null;
|
|
2444
|
+
}, onConfirmClicked: () => {
|
|
2445
|
+
var _a;
|
|
2446
|
+
this.loggedInIntlAddressConfirmDialogOpen = false;
|
|
2447
|
+
(_a = this.loggedInIntlAddressResolver) === null || _a === void 0 ? void 0 : _a.call(this, 'redirect');
|
|
2448
|
+
this.loggedInIntlAddressResolver = null;
|
|
2449
|
+
} }), index.h("zonos-confirm-dialog", { class: "zonos--close-confirm-dialog", dialogCancelBtnText: localization.translate("Don't close"), dialogConfirmBtnText: localization.translate('Close'), dialogIntent: "warn", dialogOpen: this.confirmDialogOpen, dialogSubtitle: localization.translate('Would you like to close checkout and return to the site?'), dialogTitle: localization.translate('Are you sure?'), onCancelClicked: () => {
|
|
2171
2450
|
this.confirmDialogOpen = false;
|
|
2172
2451
|
},
|
|
2173
2452
|
// Mark user selected confirm to close the dialog
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const cart = require('./cart-
|
|
6
|
+
const cart = require('./cart-e156c1e3.js');
|
|
7
7
|
const cleanHtmlMarkdown = require('./cleanHtmlMarkdown-31da84b7.js');
|
|
8
8
|
const zonosStore = require('./zonosStore-f5a61112.js');
|
|
9
9
|
const classes = require('./classes-b7918f56.js');
|
|
10
10
|
const styles = require('./styles-d1e64fb9.js');
|
|
11
|
-
require('./localization-
|
|
11
|
+
require('./localization-5bb1e598.js');
|
|
12
12
|
require('./handleFetch-954f30e1.js');
|
|
13
13
|
require('./VarianceTest-bec00ea8.js');
|
|
14
14
|
require('./isDarkColor-a68abf7a.js');
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const paypal = require('./paypal-
|
|
8
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-e156c1e3.js');
|
|
7
|
+
const paypal = require('./paypal-f9641595.js');
|
|
8
|
+
const localization = require('./localization-5bb1e598.js');
|
|
9
9
|
const zonosStore = require('./zonosStore-f5a61112.js');
|
|
10
10
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
11
11
|
const createCustomEvent = require('./createCustomEvent-7b6fad95.js');
|
|
12
12
|
const getBorderRadius = require('./getBorderRadius-27a74844.js');
|
|
13
13
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
14
14
|
const submitGtag = require('./submitGtag-cb4fb332.js');
|
|
15
|
-
const isCollectMobileTablet = require('./isCollectMobileTablet-
|
|
15
|
+
const isCollectMobileTablet = require('./isCollectMobileTablet-c9369cd8.js');
|
|
16
16
|
const classes = require('./classes-b7918f56.js');
|
|
17
17
|
const ILanguage = require('./ILanguage-98b04442.js');
|
|
18
|
-
const renderCheckoutCurrency = require('./renderCheckoutCurrency-
|
|
19
|
-
const placeTestOrder = require('./placeTestOrder-
|
|
18
|
+
const renderCheckoutCurrency = require('./renderCheckoutCurrency-6b59a718.js');
|
|
19
|
+
const placeTestOrder = require('./placeTestOrder-7ac7f91a.js');
|
|
20
20
|
const renderFallback = require('./renderFallback-bc20ee20.js');
|
|
21
21
|
require('./isDarkColor-a68abf7a.js');
|
|
22
22
|
require('./isContrastColor-d1936a5c.js');
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const isCollectMobileTablet = require('./isCollectMobileTablet-
|
|
8
|
-
const paypal = require('./paypal-
|
|
9
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-e156c1e3.js');
|
|
7
|
+
const isCollectMobileTablet = require('./isCollectMobileTablet-c9369cd8.js');
|
|
8
|
+
const paypal = require('./paypal-f9641595.js');
|
|
9
|
+
const localization = require('./localization-5bb1e598.js');
|
|
10
10
|
const zonosStore = require('./zonosStore-f5a61112.js');
|
|
11
11
|
const buildCartItemsByTempCart = require('./buildCartItemsByTempCart-edddbf4b.js');
|
|
12
12
|
const handleFetch = require('./handleFetch-954f30e1.js');
|