@zonos/elements 1.3.268 → 1.3.270
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-af7c024e.js → cart-3ff48a0e.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-0fa6e022.js → hasInclusivePrice-aec06153.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-c2e3f232.js → invoice-ff716652.js} +2 -2
- package/dist/cjs/{isCollectMobileTablet-6014787b.js → isCollectMobileTablet-3ac53cab.js} +2 -2
- package/dist/cjs/{localization-f897bc45.js → localization-5c1c9c6a.js} +245 -4
- package/dist/cjs/{paypal-6756a0da.js → paypal-c55b6c45.js} +2 -2
- package/dist/cjs/{placeTestOrder-a4874e51.js → placeTestOrder-230f534b.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-584d50fe.js → renderCheckoutCurrency-e9d8efa8.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 +15 -72
- 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-hello-dialog.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello.cjs.entry.js +2 -45
- 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-policy-consent_2.cjs.entry.js +3 -3
- package/dist/collection/components/hello/zonos-hello/zonos-hello.js +2 -44
- package/dist/collection/components/store/hello/localization.js +12 -1
- package/dist/collection/components/utils/checkout/bigcommerceStorefrontApi.js +28 -0
- package/dist/collection/components/utils/checkout/removeBigcommerceCartShipping.js +83 -0
- package/dist/collection/components/utils/hello/currencyConversion/defaultCurrencyConverter.js +6 -2
- package/dist/collection/components/utils/hello/shouldShowHelloWidget.js +61 -0
- package/dist/collection/utils/toggleBigcommerceNativeCurrencySelector.js +2 -1
- package/dist/esm/{cart-68c16805.js → cart-44fa77ef.js} +1 -1
- package/dist/esm/{hasInclusivePrice-f1ca1610.js → hasInclusivePrice-f0440925.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-d0eadc6a.js → invoice-89e71796.js} +2 -2
- package/dist/esm/{isCollectMobileTablet-11ade63f.js → isCollectMobileTablet-323d2ba1.js} +2 -2
- package/dist/esm/{localization-8e81b696.js → localization-066586b6.js} +242 -5
- package/dist/esm/{paypal-e32877e9.js → paypal-8725008c.js} +2 -2
- package/dist/esm/{placeTestOrder-4cf429d7.js → placeTestOrder-38be871e.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-9459b8a3.js → renderCheckoutCurrency-802f4481.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 +4 -61
- 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-hello-dialog.entry.js +2 -2
- package/dist/esm/zonos-hello.entry.js +2 -45
- 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-policy-consent_2.entry.js +3 -3
- package/dist/esm-es5/{cart-68c16805.js → cart-44fa77ef.js} +1 -1
- package/dist/esm-es5/{hasInclusivePrice-f1ca1610.js → hasInclusivePrice-f0440925.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-d0eadc6a.js → invoice-89e71796.js} +1 -1
- package/dist/esm-es5/{isCollectMobileTablet-11ade63f.js → isCollectMobileTablet-323d2ba1.js} +1 -1
- package/dist/esm-es5/{localization-8e81b696.js → localization-066586b6.js} +1 -1
- package/dist/esm-es5/{paypal-e32877e9.js → paypal-8725008c.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-4cf429d7.js → placeTestOrder-38be871e.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-9459b8a3.js → renderCheckoutCurrency-802f4481.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-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-policy-consent_2.entry.js +1 -1
- 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/hello/zonos-hello/zonos-hello.d.ts +0 -1
- package/dist/types/components/utils/checkout/bigcommerceStorefrontApi.d.ts +9 -0
- package/dist/types/components/utils/checkout/removeBigcommerceCartShipping.d.ts +18 -0
- package/dist/types/components/utils/hello/shouldShowHelloWidget.d.ts +16 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-8ddc21f1.system.entry.js → p-08c7dc07.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b93b66c2.entry.js → p-0d251428.entry.js} +1 -1
- package/dist/zonos-elements/{p-44b279cc.system.js → p-0d2d7fc4.system.js} +1 -1
- package/dist/zonos-elements/{p-7166df08.entry.js → p-0e9c0eff.entry.js} +1 -1
- package/dist/zonos-elements/{p-64e8f05d.system.entry.js → p-0fb8b711.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-17e3cd62.js → p-208b270a.js} +1 -1
- package/dist/zonos-elements/{p-c3459f4a.entry.js → p-225f19b6.entry.js} +1 -1
- package/dist/zonos-elements/p-238370ad.system.js +1 -0
- package/dist/zonos-elements/{p-01913da8.js → p-260a5b57.js} +1 -1
- package/dist/zonos-elements/{p-623fc89a.system.entry.js → p-2651ca93.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-5b05b461.system.js → p-27beefda.system.js} +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/{p-48805ed6.system.entry.js → p-2df84888.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e3d6f9b4.entry.js → p-2f61dc3c.entry.js} +1 -1
- package/dist/zonos-elements/{p-50362897.entry.js → p-30e819ed.entry.js} +1 -1
- package/dist/zonos-elements/{p-2ccd20c0.system.js → p-31a3b070.system.js} +1 -1
- package/dist/zonos-elements/{p-a0ee01dd.system.entry.js → p-553ca694.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-af12a1b7.system.entry.js → p-5812b323.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-95f3bbad.system.entry.js → p-5ab4bc26.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-108b5307.system.entry.js → p-5df77315.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-97da66f2.entry.js → p-6704b83e.entry.js} +1 -1
- package/dist/zonos-elements/p-69ad7325.entry.js +1 -0
- package/dist/zonos-elements/{p-1376e67f.system.entry.js → p-6ac77d9f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4fe3d5e0.system.js → p-703f2737.system.js} +1 -1
- package/dist/zonos-elements/p-72666536.system.entry.js +1 -0
- package/dist/zonos-elements/{p-b71ef46e.js → p-7792f4c2.js} +1 -1
- package/dist/zonos-elements/{p-95b460e9.system.entry.js → p-7e03bd33.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-53a59935.system.js → p-801dd8d8.system.js} +1 -1
- package/dist/zonos-elements/{p-673407b8.entry.js → p-91702715.entry.js} +1 -1
- package/dist/zonos-elements/{p-6f41c193.entry.js → p-9abfb6b0.entry.js} +1 -1
- package/dist/zonos-elements/{p-dcafbd4e.js → p-9e414000.js} +1 -1
- package/dist/zonos-elements/{p-bc9a30a1.system.entry.js → p-a2885536.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-620a9013.entry.js → p-a977cddd.entry.js} +1 -1
- package/dist/zonos-elements/{p-24091606.system.entry.js → p-acd7009a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-69089a6f.system.entry.js → p-ad4c8167.system.entry.js} +1 -1
- package/dist/zonos-elements/p-b1125711.system.js +1 -0
- package/dist/zonos-elements/p-b15ceaff.entry.js +1 -0
- package/dist/zonos-elements/p-b1a4f385.system.entry.js +1 -0
- package/dist/zonos-elements/{p-72c3756a.js → p-bea9d128.js} +1 -1
- package/dist/zonos-elements/{p-72960738.js → p-bfcc1432.js} +1 -1
- package/dist/zonos-elements/p-c049c527.js +1 -0
- package/dist/zonos-elements/p-c76ec587.system.js +1 -0
- package/dist/zonos-elements/{p-593764cf.system.entry.js → p-ccd0fa8f.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-38311c16.entry.js → p-d29dbeb3.entry.js} +1 -1
- package/dist/zonos-elements/{p-7628569a.entry.js → p-d4c966cb.entry.js} +1 -1
- package/dist/zonos-elements/p-d659153c.entry.js +1 -0
- package/dist/zonos-elements/p-debd2e30.js +1 -0
- package/dist/zonos-elements/p-e11c3410.entry.js +1 -0
- package/dist/zonos-elements/{p-7fef8558.entry.js → p-eb96d62f.entry.js} +1 -1
- package/dist/zonos-elements/{p-c91fade3.entry.js → p-ebc966d8.entry.js} +1 -1
- package/dist/zonos-elements/{p-774de1ec.system.js → p-f5d4775a.system.js} +1 -1
- package/dist/zonos-elements/{p-5e18d92b.system.entry.js → p-fb83134b.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c7ca3e98.system.entry.js → p-fc651784.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-fc5007e0.entry.js → p-fcf3ed5c.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-000b895a.entry.js +0 -1
- package/dist/zonos-elements/p-06e7fe2a.system.entry.js +0 -1
- package/dist/zonos-elements/p-0803ad10.js +0 -1
- package/dist/zonos-elements/p-11439d12.entry.js +0 -1
- package/dist/zonos-elements/p-17be8409.entry.js +0 -1
- package/dist/zonos-elements/p-1eef8c23.system.js +0 -1
- package/dist/zonos-elements/p-5fa2395d.system.js +0 -1
- package/dist/zonos-elements/p-7a220941.system.js +0 -1
- package/dist/zonos-elements/p-7cf8e1f0.js +0 -1
- package/dist/zonos-elements/p-8116d3ba.entry.js +0 -1
- package/dist/zonos-elements/p-b9a615bc.system.entry.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const zonosStore = require('./zonosStore-45a87908.js');
|
|
4
|
-
const localization = require('./localization-
|
|
4
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
5
5
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
6
6
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
7
7
|
const isDarkColor = require('./isDarkColor-5d6ca405.js');
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -133,7 +133,7 @@ const getZonosQaUrl = () => {
|
|
|
133
133
|
return null;
|
|
134
134
|
}
|
|
135
135
|
const qaUrl = extractZonosQaUrl(window.location.href);
|
|
136
|
-
const cdnUrl = "https://v1.3.
|
|
136
|
+
const cdnUrl = "https://v1.3.270.js.zonos.com";
|
|
137
137
|
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
138
138
|
if (!qaUrl &&
|
|
139
139
|
(cdnUrl.includes('test.') ||
|
|
@@ -381,10 +381,10 @@ const zonosLoadUrl = (() => {
|
|
|
381
381
|
return null;
|
|
382
382
|
})();
|
|
383
383
|
const startLoadTime = Date.now();
|
|
384
|
-
const ZONOS_URL = "https://v1.3.
|
|
385
|
-
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.
|
|
386
|
-
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.
|
|
387
|
-
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.
|
|
384
|
+
const ZONOS_URL = "https://v1.3.270.js.zonos.com";
|
|
385
|
+
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.3.270";
|
|
386
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.3.270";
|
|
387
|
+
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.3.270";
|
|
388
388
|
const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
|
|
389
389
|
const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
|
|
390
390
|
class Zonos {
|
|
@@ -402,7 +402,7 @@ Zonos.iframeLogType = typeof window !== 'undefined'
|
|
|
402
402
|
? new URLSearchParams(window.location.search).get('iframeLogType')
|
|
403
403
|
: null;
|
|
404
404
|
Zonos.isBigCommerce = false;
|
|
405
|
-
Zonos.releaseDate = "
|
|
405
|
+
Zonos.releaseDate = "1781713868966";
|
|
406
406
|
Zonos.isLegacyCheckout = false;
|
|
407
407
|
Zonos.googleAnalyticId = null;
|
|
408
408
|
Zonos.googleAnalyticReady = false;
|
|
@@ -427,7 +427,7 @@ Zonos.isNpm = true;
|
|
|
427
427
|
Zonos.zonosQaUrl = null;
|
|
428
428
|
Zonos.zonosQaUrlApi = null;
|
|
429
429
|
Zonos.trackEventLogs = [];
|
|
430
|
-
Zonos.version = `v${"1.3.
|
|
430
|
+
Zonos.version = `v${"1.3.270"}`;
|
|
431
431
|
Zonos.modeAlerted = false;
|
|
432
432
|
Zonos.cartData = null;
|
|
433
433
|
Zonos.paypal = null;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const zonosStore = require('./zonosStore-45a87908.js');
|
|
4
|
-
const cart = require('./cart-
|
|
5
|
-
const localization = require('./localization-
|
|
4
|
+
const cart = require('./cart-3ff48a0e.js');
|
|
5
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
6
6
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
7
7
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const zonosStore = require('./zonosStore-45a87908.js');
|
|
4
|
-
const cart = require('./cart-
|
|
5
|
-
const localization = require('./localization-
|
|
4
|
+
const cart = require('./cart-3ff48a0e.js');
|
|
5
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
6
6
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
7
7
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
8
8
|
|
|
@@ -17184,6 +17184,229 @@ const getShippingZones = async () => {
|
|
|
17184
17184
|
return shippingZones || null;
|
|
17185
17185
|
};
|
|
17186
17186
|
|
|
17187
|
+
/**
|
|
17188
|
+
* Fetch the checkout/cart ID from the BigCommerce Storefront Cart API.
|
|
17189
|
+
* The `/checkout` page URL does not include the checkout ID, so we
|
|
17190
|
+
* retrieve it from `/api/storefront/cart` which returns the active cart(s).
|
|
17191
|
+
*/
|
|
17192
|
+
const fetchCheckoutId = async () => {
|
|
17193
|
+
var _a, _b;
|
|
17194
|
+
try {
|
|
17195
|
+
const response = await fetch('/api/storefront/cart', {
|
|
17196
|
+
credentials: 'same-origin',
|
|
17197
|
+
headers: {
|
|
17198
|
+
Accept: 'application/json',
|
|
17199
|
+
},
|
|
17200
|
+
});
|
|
17201
|
+
if (!response.ok) {
|
|
17202
|
+
VarianceTest.log(`Failed to fetch BigCommerce cart: ${String(response.status)}`, 'error');
|
|
17203
|
+
return null;
|
|
17204
|
+
}
|
|
17205
|
+
const carts = (await response.json());
|
|
17206
|
+
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;
|
|
17207
|
+
}
|
|
17208
|
+
catch (error) {
|
|
17209
|
+
handleFetch.logError('Error fetching BigCommerce cart data', error);
|
|
17210
|
+
return null;
|
|
17211
|
+
}
|
|
17212
|
+
};
|
|
17213
|
+
/**
|
|
17214
|
+
* Fetch checkout data from the BigCommerce Storefront API.
|
|
17215
|
+
* This API is cookie-authenticated (same-origin), so no token is needed.
|
|
17216
|
+
*/
|
|
17217
|
+
const fetchBigCommerceCheckout = async (checkoutId) => {
|
|
17218
|
+
try {
|
|
17219
|
+
const response = await fetch(`/api/storefront/checkouts/${checkoutId}?include=customer.customerGroup,customer.addresses`, {
|
|
17220
|
+
credentials: 'same-origin',
|
|
17221
|
+
headers: {
|
|
17222
|
+
Accept: 'application/json',
|
|
17223
|
+
'Content-Type': 'application/json',
|
|
17224
|
+
},
|
|
17225
|
+
});
|
|
17226
|
+
if (!response.ok) {
|
|
17227
|
+
VarianceTest.log(`Failed to fetch BigCommerce checkout: ${String(response.status)}`, 'error');
|
|
17228
|
+
return null;
|
|
17229
|
+
}
|
|
17230
|
+
return (await response.json());
|
|
17231
|
+
}
|
|
17232
|
+
catch (error) {
|
|
17233
|
+
handleFetch.logError('Error fetching BigCommerce checkout data', error);
|
|
17234
|
+
return null;
|
|
17235
|
+
}
|
|
17236
|
+
};
|
|
17237
|
+
/**
|
|
17238
|
+
* Delete a consignment (a saved shipping selection, e.g. a domestic shipping
|
|
17239
|
+
* quote the shopper added on the cart page) from the active BigCommerce
|
|
17240
|
+
* checkout via the Storefront API. Cookie-authenticated (same-origin), so no
|
|
17241
|
+
* token is needed. Returns the updated checkout on success, or null on
|
|
17242
|
+
* failure.
|
|
17243
|
+
*/
|
|
17244
|
+
const deleteBigCommerceConsignment = async (checkoutId, consignmentId) => {
|
|
17245
|
+
try {
|
|
17246
|
+
const response = await fetch(`/api/storefront/checkouts/${checkoutId}/consignments/${consignmentId}`, {
|
|
17247
|
+
credentials: 'same-origin',
|
|
17248
|
+
headers: {
|
|
17249
|
+
Accept: 'application/json',
|
|
17250
|
+
'Content-Type': 'application/json',
|
|
17251
|
+
},
|
|
17252
|
+
method: 'DELETE',
|
|
17253
|
+
});
|
|
17254
|
+
if (!response.ok) {
|
|
17255
|
+
VarianceTest.log(`Failed to delete BigCommerce consignment: ${String(response.status)}`, 'error');
|
|
17256
|
+
return null;
|
|
17257
|
+
}
|
|
17258
|
+
return (await response.json());
|
|
17259
|
+
}
|
|
17260
|
+
catch (error) {
|
|
17261
|
+
handleFetch.logError('Error deleting BigCommerce consignment', error);
|
|
17262
|
+
return null;
|
|
17263
|
+
}
|
|
17264
|
+
};
|
|
17265
|
+
/**
|
|
17266
|
+
* Whether the BigCommerce shopper is already logged in. We key off the
|
|
17267
|
+
* customer's numeric `id` since the storefront API populates it only for
|
|
17268
|
+
* authenticated sessions (guest checkouts have an empty `customer` object).
|
|
17269
|
+
*/
|
|
17270
|
+
const isBigCommerceCustomerLoggedIn = (checkout) => { var _a; return !!((_a = checkout === null || checkout === void 0 ? void 0 : checkout.customer) === null || _a === void 0 ? void 0 : _a.id); };
|
|
17271
|
+
|
|
17272
|
+
/**
|
|
17273
|
+
* Whether the Hello widget should be shown for the current shopper. This is the
|
|
17274
|
+
* single source of truth for Hello's visibility decision — the `zonos-hello`
|
|
17275
|
+
* component renders by it, and other features (e.g. BigCommerce cart shipping
|
|
17276
|
+
* cleanup) gate on it so their behavior stays in lockstep with what the shopper
|
|
17277
|
+
* actually sees.
|
|
17278
|
+
*
|
|
17279
|
+
* Resolves the configured `widgetVisibility` behavior (with the deprecated
|
|
17280
|
+
* `showForCountries` override) against the selected country and shipping-zone
|
|
17281
|
+
* state, then applies the include/exclude country overrides.
|
|
17282
|
+
*
|
|
17283
|
+
* @param showLog - emit a debug log when the shopper is not in a shipping zone.
|
|
17284
|
+
* Defaults to `true`; pass `false` from non-rendering callers to avoid log
|
|
17285
|
+
* noise.
|
|
17286
|
+
*/
|
|
17287
|
+
const shouldShowHelloWidget = (showLog = true) => {
|
|
17288
|
+
var _a, _b;
|
|
17289
|
+
if (!localizationStore.localizationLoaded) {
|
|
17290
|
+
return false;
|
|
17291
|
+
}
|
|
17292
|
+
const { countryDisplayRules, showForCountries } = zonosStore.zonosStore.helloSettings;
|
|
17293
|
+
const visibilityRules = countryDisplayRules === null || countryDisplayRules === void 0 ? void 0 : countryDisplayRules.widgetVisibility;
|
|
17294
|
+
const selectedCountry = localizationStore.selectedCountryCode;
|
|
17295
|
+
// Resolve behavior: deprecated showForCountries overrides widgetVisibility.behavior
|
|
17296
|
+
// If showForCountries is an array of country codes, treat as legacy explicit list
|
|
17297
|
+
const behavior = Array.isArray(showForCountries)
|
|
17298
|
+
? showForCountries
|
|
17299
|
+
: (showForCountries !== null && showForCountries !== void 0 ? showForCountries : visibilityRules === null || visibilityRules === void 0 ? void 0 : visibilityRules.behavior);
|
|
17300
|
+
if (showLog && !localizationStore.isShippableCountry) {
|
|
17301
|
+
VarianceTest.log(`Hello: not shippable country - Show for countries: ${behavior}`);
|
|
17302
|
+
}
|
|
17303
|
+
// Legacy: explicit list of country codes from deprecated showForCountries
|
|
17304
|
+
if (Array.isArray(behavior)) {
|
|
17305
|
+
return !!selectedCountry && behavior.includes(selectedCountry);
|
|
17306
|
+
}
|
|
17307
|
+
// Determine base visibility from behavior
|
|
17308
|
+
let isVisible;
|
|
17309
|
+
if (behavior === 'ALL') {
|
|
17310
|
+
isVisible = true;
|
|
17311
|
+
}
|
|
17312
|
+
else {
|
|
17313
|
+
// Default: ONLY_SHIPPABLE
|
|
17314
|
+
isVisible = localizationStore.isShippableCountry;
|
|
17315
|
+
}
|
|
17316
|
+
// Apply includedCountries — force show the widget for these countries
|
|
17317
|
+
if (!isVisible &&
|
|
17318
|
+
selectedCountry &&
|
|
17319
|
+
((_a = visibilityRules === null || visibilityRules === void 0 ? void 0 : visibilityRules.includedCountries) === null || _a === void 0 ? void 0 : _a.includes(selectedCountry))) {
|
|
17320
|
+
isVisible = true;
|
|
17321
|
+
}
|
|
17322
|
+
// Apply excludedCountries — force hide the widget for these countries
|
|
17323
|
+
if (isVisible &&
|
|
17324
|
+
selectedCountry &&
|
|
17325
|
+
((_b = visibilityRules === null || visibilityRules === void 0 ? void 0 : visibilityRules.excludedCountries) === null || _b === void 0 ? void 0 : _b.includes(selectedCountry))) {
|
|
17326
|
+
isVisible = false;
|
|
17327
|
+
}
|
|
17328
|
+
return isVisible;
|
|
17329
|
+
};
|
|
17330
|
+
|
|
17331
|
+
/**
|
|
17332
|
+
* Guard against overlapping passes. `removeBigcommerceCartShipping` is fired on
|
|
17333
|
+
* every country change; without this flag, rapid country switches could stack
|
|
17334
|
+
* concurrent fetch/DELETE cycles against the same cart before the reload kicks
|
|
17335
|
+
* in.
|
|
17336
|
+
*/
|
|
17337
|
+
let isRemoving = false;
|
|
17338
|
+
/**
|
|
17339
|
+
* On the BigCommerce cart page, drop any native domestic shipping quote the
|
|
17340
|
+
* shopper added before they switched to an international country, then reload
|
|
17341
|
+
* the page.
|
|
17342
|
+
*
|
|
17343
|
+
* The native cart stores a shipping estimate as a consignment on the active
|
|
17344
|
+
* checkout. When Hello is shown the shopper is checking out internationally
|
|
17345
|
+
* through Zonos, so that domestic shipping cost should not linger in the Grand
|
|
17346
|
+
* Total. We delete the consignment(s) and reload so the server re-renders the
|
|
17347
|
+
* cart consistently (subtotal, shipping, and Grand Total all add up).
|
|
17348
|
+
*
|
|
17349
|
+
* No-ops unless all of the following hold: the host is BigCommerce, the shopper
|
|
17350
|
+
* is on the cart page, they are in a shipping zone with Hello shown, and the
|
|
17351
|
+
* active checkout actually has a consignment. Because the reload happens only
|
|
17352
|
+
* when a consignment is found and removed, the freshly-loaded page has none —
|
|
17353
|
+
* so this cannot loop.
|
|
17354
|
+
*/
|
|
17355
|
+
const removeBigcommerceCartShipping = async () => {
|
|
17356
|
+
var _a, _b;
|
|
17357
|
+
if (typeof window === 'undefined' || !((_a = window.Zonos) === null || _a === void 0 ? void 0 : _a.isBigCommerce)) {
|
|
17358
|
+
return;
|
|
17359
|
+
}
|
|
17360
|
+
// Only on the cart page and only when Hello is shown — elsewhere there is no
|
|
17361
|
+
// Grand Total to correct. Gate on Hello visibility (not raw shipping-zone
|
|
17362
|
+
// membership) so include/exclude country overrides are respected.
|
|
17363
|
+
if (window.location.pathname !== '/cart.php' ||
|
|
17364
|
+
!localizationStore.isShippableCountry ||
|
|
17365
|
+
!shouldShowHelloWidget(false)) {
|
|
17366
|
+
return;
|
|
17367
|
+
}
|
|
17368
|
+
if (isRemoving) {
|
|
17369
|
+
return;
|
|
17370
|
+
}
|
|
17371
|
+
isRemoving = true;
|
|
17372
|
+
try {
|
|
17373
|
+
const checkoutId = await fetchCheckoutId();
|
|
17374
|
+
if (!checkoutId) {
|
|
17375
|
+
return;
|
|
17376
|
+
}
|
|
17377
|
+
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
17378
|
+
const consignmentIds = ((_b = checkout === null || checkout === void 0 ? void 0 : checkout.consignments) !== null && _b !== void 0 ? _b : [])
|
|
17379
|
+
.map(consignment => consignment.id)
|
|
17380
|
+
.filter((id) => !!id);
|
|
17381
|
+
// Nothing to do if there is no domestic shipping quote on the cart.
|
|
17382
|
+
if (!consignmentIds.length) {
|
|
17383
|
+
return;
|
|
17384
|
+
}
|
|
17385
|
+
VarianceTest.log(`Removing ${String(consignmentIds.length)} BigCommerce cart consignment(s) for international shopper`, 'info');
|
|
17386
|
+
// `deleteBigCommerceConsignment` resolves to null on failure (it swallows
|
|
17387
|
+
// the error and logs it), so a non-null result means that consignment was
|
|
17388
|
+
// actually removed.
|
|
17389
|
+
const deleteResults = await Promise.all(consignmentIds.map(consignmentId => deleteBigCommerceConsignment(checkoutId, consignmentId)));
|
|
17390
|
+
const removedCount = deleteResults.filter(Boolean).length;
|
|
17391
|
+
// Only reload when at least one consignment was actually removed. If every
|
|
17392
|
+
// DELETE failed, reloading would re-run this on init with the same
|
|
17393
|
+
// consignments still present and trap the shopper in a reload loop.
|
|
17394
|
+
if (!removedCount) {
|
|
17395
|
+
VarianceTest.log('No BigCommerce cart consignments were removed; skipping reload to avoid a reload loop', 'warn');
|
|
17396
|
+
return;
|
|
17397
|
+
}
|
|
17398
|
+
// Reload so the server re-renders the cart consistently without the removed
|
|
17399
|
+
// shipping, instead of surgically patching the DOM total.
|
|
17400
|
+
window.location.reload();
|
|
17401
|
+
}
|
|
17402
|
+
catch (error) {
|
|
17403
|
+
handleFetch.logError('Error removing BigCommerce cart shipping consignment', error);
|
|
17404
|
+
}
|
|
17405
|
+
finally {
|
|
17406
|
+
isRemoving = false;
|
|
17407
|
+
}
|
|
17408
|
+
};
|
|
17409
|
+
|
|
17187
17410
|
const applyInclusiveEffectiveRate = (amount) => {
|
|
17188
17411
|
const inclusivePrice = localizationStore.inclusivePricingConfigurations.find(x => x.shipToCountry === localizationStore.selectedCountryCode);
|
|
17189
17412
|
if (!inclusivePrice) {
|
|
@@ -17448,8 +17671,12 @@ const convertCurrency = (element) => {
|
|
|
17448
17671
|
rate !== currentIntlRateValue ||
|
|
17449
17672
|
// Update currency when the country code changes
|
|
17450
17673
|
currentCountryValue !== localizationStore.selectedCountryCode)) {
|
|
17451
|
-
|
|
17452
|
-
|
|
17674
|
+
let timeoutId;
|
|
17675
|
+
// Only trigger blur effect if the source currency is different from the target currency
|
|
17676
|
+
if (zonosStore.zonosStore.sourceCurrency !== localizationStore.targetCurrency) {
|
|
17677
|
+
// Hide the currency until DOM is ready to display the new value
|
|
17678
|
+
timeoutId = performBlurSpecificElement(element);
|
|
17679
|
+
}
|
|
17453
17680
|
const appliedInclusivePrice = applyInclusiveEffectiveRate(amount);
|
|
17454
17681
|
const customizedCurrencyFormat = typeof zonosStore.zonosStore.currencyConverter === 'function' &&
|
|
17455
17682
|
zonosStore.zonosStore.currencyConverter({
|
|
@@ -17574,7 +17801,7 @@ const toggleBigcommerceNativeCurrencySelector = () => {
|
|
|
17574
17801
|
return;
|
|
17575
17802
|
}
|
|
17576
17803
|
const bigcommerceCurrencyCode = document.body.dataset.currencyCode;
|
|
17577
|
-
const shouldHide = localizationStore.isShippableCountry &&
|
|
17804
|
+
const shouldHide = (shouldShowHelloWidget(false) || localizationStore.isShippableCountry) &&
|
|
17578
17805
|
!!bigcommerceCurrencyCode &&
|
|
17579
17806
|
bigcommerceCurrencyCode === zonosStore.zonosStore.sourceCurrency;
|
|
17580
17807
|
try {
|
|
@@ -17759,6 +17986,11 @@ const localizationStoreUpdateSelectedCountryCode = ({ isInitializing, newSelecte
|
|
|
17759
17986
|
// because `currencyDisplay` is also invoked from the price-mutation
|
|
17760
17987
|
// observer in `zonos-hello.tsx`, which fires on every DOM render.
|
|
17761
17988
|
toggleBigcommerceNativeCurrencySelector();
|
|
17989
|
+
// On the BigCommerce cart page, drop any native domestic shipping quote the
|
|
17990
|
+
// shopper added before switching to an international country so the Grand
|
|
17991
|
+
// Total reflects only subtotal + coupon. No-ops off-cart, off-BigCommerce,
|
|
17992
|
+
// for non-shippable countries, or when the cart has no consignment.
|
|
17993
|
+
void removeBigcommerceCartShipping();
|
|
17762
17994
|
if (!selectedCountryCode) {
|
|
17763
17995
|
return;
|
|
17764
17996
|
}
|
|
@@ -17936,7 +18168,12 @@ const initLocalizationStore = async () => {
|
|
|
17936
18168
|
newSelectedCountryCode: 'CA',
|
|
17937
18169
|
});
|
|
17938
18170
|
}
|
|
17939
|
-
localizationStore.localizationLoaded
|
|
18171
|
+
if (!localizationStore.localizationLoaded) {
|
|
18172
|
+
localizationStore.localizationLoaded = true;
|
|
18173
|
+
void removeBigcommerceCartShipping();
|
|
18174
|
+
// shouldShowHelloWidget is false because localization is not loaded yet
|
|
18175
|
+
void toggleBigcommerceNativeCurrencySelector();
|
|
18176
|
+
}
|
|
17940
18177
|
};
|
|
17941
18178
|
|
|
17942
18179
|
exports.VARIANT_TEST_KEY_EXPIRATION = VARIANT_TEST_KEY_EXPIRATION;
|
|
@@ -17945,17 +18182,21 @@ exports.currencyConvert = currencyConvert;
|
|
|
17945
18182
|
exports.currencyConvertAndFormat = currencyConvertAndFormat;
|
|
17946
18183
|
exports.currencyDisplay = currencyDisplay;
|
|
17947
18184
|
exports.currencyFormat = currencyFormat;
|
|
18185
|
+
exports.fetchBigCommerceCheckout = fetchBigCommerceCheckout;
|
|
18186
|
+
exports.fetchCheckoutId = fetchCheckoutId;
|
|
17948
18187
|
exports.filterValidTests = filterValidTests;
|
|
17949
18188
|
exports.getFallbackDefaultCountryCode = getFallbackDefaultCountryCode;
|
|
17950
18189
|
exports.getOverridenZCountry = getOverridenZCountry;
|
|
17951
18190
|
exports.getZCountryUrlParam = getZCountryUrlParam;
|
|
17952
18191
|
exports.initLocalizationStore = initLocalizationStore;
|
|
18192
|
+
exports.isBigCommerceCustomerLoggedIn = isBigCommerceCustomerLoggedIn;
|
|
17953
18193
|
exports.isValidSelector = isValidSelector;
|
|
17954
18194
|
exports.localizationStore = localizationStore;
|
|
17955
18195
|
exports.localizationStoreOnChange = localizationStoreOnChange;
|
|
17956
18196
|
exports.localizationStoreUpdateSelectedCountryCode = localizationStoreUpdateSelectedCountryCode;
|
|
17957
18197
|
exports.localizationStoreUpdateSelectedLocale = localizationStoreUpdateSelectedLocale;
|
|
17958
18198
|
exports.setZCountryUrlParam = setZCountryUrlParam;
|
|
18199
|
+
exports.shouldShowHelloWidget = shouldShowHelloWidget;
|
|
17959
18200
|
exports.storageStore = storageStore;
|
|
17960
18201
|
exports.storageStoreOnChange = storageStoreOnChange;
|
|
17961
18202
|
exports.storageStoreSetEnabledVariantTestKeys = storageStoreSetEnabledVariantTestKeys;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const zonosStore = require('./zonosStore-45a87908.js');
|
|
4
|
-
const cart = require('./cart-
|
|
5
|
-
const localization = require('./localization-
|
|
4
|
+
const cart = require('./cart-3ff48a0e.js');
|
|
5
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
6
6
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
7
7
|
const isContrastColor = require('./isContrastColor-76592c92.js');
|
|
8
8
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const cart = require('./cart-
|
|
4
|
-
const localization = require('./localization-
|
|
3
|
+
const cart = require('./cart-3ff48a0e.js');
|
|
4
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
5
5
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
6
6
|
|
|
7
7
|
const placeTestOrder = async () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const cart = require('./cart-
|
|
4
|
-
const localization = require('./localization-
|
|
3
|
+
const cart = require('./cart-3ff48a0e.js');
|
|
4
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
5
5
|
|
|
6
6
|
const getDisplayCurrency = () => {
|
|
7
7
|
var _a, _b;
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const localization = require('./localization-
|
|
6
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
7
7
|
const containsNonLatinChars = require('./containsNonLatinChars-2be5129b.js');
|
|
8
|
-
const cart = require('./cart-
|
|
8
|
+
const cart = require('./cart-3ff48a0e.js');
|
|
9
9
|
const classes = require('./classes-b7918f56.js');
|
|
10
10
|
const getBorderRadius = require('./getBorderRadius-fc683d94.js');
|
|
11
11
|
const zonosStore = require('./zonosStore-45a87908.js');
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
6
|
const throttle = require('./throttle-02c2e917.js');
|
|
7
|
-
const cart = require('./cart-
|
|
8
|
-
const localization = require('./localization-
|
|
7
|
+
const cart = require('./cart-3ff48a0e.js');
|
|
8
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
9
9
|
const zonosStore = require('./zonosStore-45a87908.js');
|
|
10
10
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
11
11
|
const shouldRenderTaxIdInput = require('./shouldRenderTaxIdInput-b8abf6de.js');
|
|
@@ -6,10 +6,10 @@ const index = require('./index-b1f95d96.js');
|
|
|
6
6
|
const zonosStore = require('./zonosStore-45a87908.js');
|
|
7
7
|
const classes = require('./classes-b7918f56.js');
|
|
8
8
|
const getBorderRadius = require('./getBorderRadius-fc683d94.js');
|
|
9
|
-
const cart = require('./cart-
|
|
10
|
-
const localization = require('./localization-
|
|
9
|
+
const cart = require('./cart-3ff48a0e.js');
|
|
10
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
11
11
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
12
|
-
const paypal = require('./paypal-
|
|
12
|
+
const paypal = require('./paypal-c55b6c45.js');
|
|
13
13
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
14
14
|
require('./isDarkColor-5d6ca405.js');
|
|
15
15
|
require('./isContrastColor-76592c92.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 localization = require('./localization-
|
|
8
|
-
const renderCheckoutCurrency = require('./renderCheckoutCurrency-
|
|
6
|
+
const cart = require('./cart-3ff48a0e.js');
|
|
7
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
8
|
+
const renderCheckoutCurrency = require('./renderCheckoutCurrency-e9d8efa8.js');
|
|
9
9
|
const cleanHtmlMarkdown = require('./cleanHtmlMarkdown-31da84b7.js');
|
|
10
10
|
const classes = require('./classes-b7918f56.js');
|
|
11
11
|
const zonosStore = require('./zonosStore-45a87908.js');
|
|
12
|
-
const hasInclusivePrice = require('./hasInclusivePrice-
|
|
13
|
-
const paypal = require('./paypal-
|
|
12
|
+
const hasInclusivePrice = require('./hasInclusivePrice-aec06153.js');
|
|
13
|
+
const paypal = require('./paypal-c55b6c45.js');
|
|
14
14
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
15
15
|
const createCustomEvent = require('./createCustomEvent-7b6fad95.js');
|
|
16
16
|
const getBorderRadius = require('./getBorderRadius-fc683d94.js');
|
|
17
17
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
18
18
|
const ILanguage = require('./ILanguage-98b04442.js');
|
|
19
|
-
const placeTestOrder = require('./placeTestOrder-
|
|
19
|
+
const placeTestOrder = require('./placeTestOrder-230f534b.js');
|
|
20
20
|
const isDarkColor = require('./isDarkColor-5d6ca405.js');
|
|
21
21
|
const getContrastColor = require('./getContrastColor-d5134ef3.js');
|
|
22
22
|
const isColorVariable = require('./isColorVariable-525dbfa7.js');
|
|
@@ -3,9 +3,9 @@
|
|
|
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-3ff48a0e.js');
|
|
7
|
+
const paypal = require('./paypal-c55b6c45.js');
|
|
8
|
+
const localization = require('./localization-5c1c9c6a.js');
|
|
9
9
|
const zonosStore = require('./zonosStore-45a87908.js');
|
|
10
10
|
const buildCartItemsByTempCart = require('./buildCartItemsByTempCart-edddbf4b.js');
|
|
11
11
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
@@ -97,63 +97,6 @@ const buildCartUrl = ({ cartId, checkoutSessionId, customerAddress1, customerAdd
|
|
|
97
97
|
return `${hostedCheckoutUrl}?${urlParams.toString()}`;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
/**
|
|
101
|
-
* Fetch the checkout/cart ID from the BigCommerce Storefront Cart API.
|
|
102
|
-
* The `/checkout` page URL does not include the checkout ID, so we
|
|
103
|
-
* retrieve it from `/api/storefront/cart` which returns the active cart(s).
|
|
104
|
-
*/
|
|
105
|
-
const fetchCheckoutId = async () => {
|
|
106
|
-
var _a, _b;
|
|
107
|
-
try {
|
|
108
|
-
const response = await fetch('/api/storefront/cart', {
|
|
109
|
-
credentials: 'same-origin',
|
|
110
|
-
headers: {
|
|
111
|
-
Accept: 'application/json',
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
if (!response.ok) {
|
|
115
|
-
VarianceTest.log(`Failed to fetch BigCommerce cart: ${String(response.status)}`, 'error');
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
const carts = (await response.json());
|
|
119
|
-
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;
|
|
120
|
-
}
|
|
121
|
-
catch (error) {
|
|
122
|
-
handleFetch.logError('Error fetching BigCommerce cart data', error);
|
|
123
|
-
return null;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* Fetch checkout data from the BigCommerce Storefront API.
|
|
128
|
-
* This API is cookie-authenticated (same-origin), so no token is needed.
|
|
129
|
-
*/
|
|
130
|
-
const fetchBigCommerceCheckout = async (checkoutId) => {
|
|
131
|
-
try {
|
|
132
|
-
const response = await fetch(`/api/storefront/checkouts/${checkoutId}?include=customer.customerGroup,customer.addresses`, {
|
|
133
|
-
credentials: 'same-origin',
|
|
134
|
-
headers: {
|
|
135
|
-
Accept: 'application/json',
|
|
136
|
-
'Content-Type': 'application/json',
|
|
137
|
-
},
|
|
138
|
-
});
|
|
139
|
-
if (!response.ok) {
|
|
140
|
-
VarianceTest.log(`Failed to fetch BigCommerce checkout: ${String(response.status)}`, 'error');
|
|
141
|
-
return null;
|
|
142
|
-
}
|
|
143
|
-
return (await response.json());
|
|
144
|
-
}
|
|
145
|
-
catch (error) {
|
|
146
|
-
handleFetch.logError('Error fetching BigCommerce checkout data', error);
|
|
147
|
-
return null;
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* Whether the BigCommerce shopper is already logged in. We key off the
|
|
152
|
-
* customer's numeric `id` since the storefront API populates it only for
|
|
153
|
-
* authenticated sessions (guest checkouts have an empty `customer` object).
|
|
154
|
-
*/
|
|
155
|
-
const isBigCommerceCustomerLoggedIn = (checkout) => { var _a; return !!((_a = checkout === null || checkout === void 0 ? void 0 : checkout.customer) === null || _a === void 0 ? void 0 : _a.id); };
|
|
156
|
-
|
|
157
100
|
/**
|
|
158
101
|
* The query flag that BigCommerce carries back to `cart.php` after the
|
|
159
102
|
* shopper logs in. When present, Zonos-elements knows to resume the
|
|
@@ -270,7 +213,7 @@ const fetchBypassOutcome = async (preFetched) => {
|
|
|
270
213
|
// caller-supplied data when available.
|
|
271
214
|
const checkoutId = preFetched
|
|
272
215
|
? preFetched.checkoutId
|
|
273
|
-
: await fetchCheckoutId();
|
|
216
|
+
: await localization.fetchCheckoutId();
|
|
274
217
|
if (!checkoutId) {
|
|
275
218
|
// No active cart yet — inconclusive. Common on fresh sessions where
|
|
276
219
|
// `initBigCommerceBypassCheck` runs before the user has added anything
|
|
@@ -280,7 +223,7 @@ const fetchBypassOutcome = async (preFetched) => {
|
|
|
280
223
|
}
|
|
281
224
|
const checkout = preFetched
|
|
282
225
|
? preFetched.checkout
|
|
283
|
-
: await fetchBigCommerceCheckout(checkoutId);
|
|
226
|
+
: await localization.fetchBigCommerceCheckout(checkoutId);
|
|
284
227
|
if (!checkout) {
|
|
285
228
|
// API call failed (network error, non-200, etc.) — inconclusive.
|
|
286
229
|
// Caching this would permanently disable bypass for the session if
|
|
@@ -535,7 +478,7 @@ const checkBigCommerceForceLogin = async ({ preFetched, } = {}) => {
|
|
|
535
478
|
}
|
|
536
479
|
const checkoutId = preFetched
|
|
537
480
|
? preFetched.checkoutId
|
|
538
|
-
: await fetchCheckoutId();
|
|
481
|
+
: await localization.fetchCheckoutId();
|
|
539
482
|
if (!checkoutId) {
|
|
540
483
|
// No active cart — nothing to protect. Force-login only matters once
|
|
541
484
|
// the shopper has a cart we're about to carry into Zonos checkout.
|
|
@@ -543,7 +486,7 @@ const checkBigCommerceForceLogin = async ({ preFetched, } = {}) => {
|
|
|
543
486
|
}
|
|
544
487
|
const checkout = preFetched
|
|
545
488
|
? preFetched.checkout
|
|
546
|
-
: await fetchBigCommerceCheckout(checkoutId);
|
|
489
|
+
: await localization.fetchBigCommerceCheckout(checkoutId);
|
|
547
490
|
if (!checkout) {
|
|
548
491
|
// Storefront API failure — fail open so a transient outage doesn't
|
|
549
492
|
// block the shopper. The merchant's BC checkout will still enforce
|
|
@@ -551,7 +494,7 @@ const checkBigCommerceForceLogin = async ({ preFetched, } = {}) => {
|
|
|
551
494
|
VarianceTest.log('BigCommerce force-login check: failed to fetch checkout data, allowing flow to continue', 'info');
|
|
552
495
|
return SKIP;
|
|
553
496
|
}
|
|
554
|
-
if (isBigCommerceCustomerLoggedIn(checkout)) {
|
|
497
|
+
if (localization.isBigCommerceCustomerLoggedIn(checkout)) {
|
|
555
498
|
return SKIP;
|
|
556
499
|
}
|
|
557
500
|
VarianceTest.log('BigCommerce force-login check: guest shopper on no-guest-checkout store, redirecting to /login.php', 'info');
|
|
@@ -768,11 +711,11 @@ const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelecte
|
|
|
768
711
|
// function always needs the checkout for the address check, so reusing one
|
|
769
712
|
// fetch avoids the earlier 4x round-trip fan-out where bypass, address
|
|
770
713
|
// lookup, and force-login each fetched independently.
|
|
771
|
-
const checkoutId = await fetchCheckoutId();
|
|
714
|
+
const checkoutId = await localization.fetchCheckoutId();
|
|
772
715
|
if (!checkoutId) {
|
|
773
716
|
return 'noAction';
|
|
774
717
|
}
|
|
775
|
-
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
718
|
+
const checkout = await localization.fetchBigCommerceCheckout(checkoutId);
|
|
776
719
|
const preFetched = { checkout, checkoutId };
|
|
777
720
|
// Check if the customer belongs to a bypass group (e.g. resellers) before
|
|
778
721
|
// redirecting them away from BigCommerce native checkout. This delegates to
|
|
@@ -874,9 +817,9 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
|
|
|
874
817
|
// changes — prevents stale customer-group data from a cached fetch. Share
|
|
875
818
|
// one fetch between the bypass and force-login decisions so this poll
|
|
876
819
|
// tick does 2 Storefront API round trips instead of 4.
|
|
877
|
-
const checkoutId = await fetchCheckoutId();
|
|
820
|
+
const checkoutId = await localization.fetchCheckoutId();
|
|
878
821
|
const checkout = checkoutId
|
|
879
|
-
? await fetchBigCommerceCheckout(checkoutId)
|
|
822
|
+
? await localization.fetchBigCommerceCheckout(checkoutId)
|
|
880
823
|
: null;
|
|
881
824
|
const preFetched = { checkout, checkoutId };
|
|
882
825
|
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup({
|
|
@@ -1640,12 +1583,12 @@ const ZonosCheckout = class {
|
|
|
1640
1583
|
if (hasManualDefault) {
|
|
1641
1584
|
return;
|
|
1642
1585
|
}
|
|
1643
|
-
const checkoutId = await fetchCheckoutId();
|
|
1586
|
+
const checkoutId = await localization.fetchCheckoutId();
|
|
1644
1587
|
if (!checkoutId) {
|
|
1645
1588
|
return;
|
|
1646
1589
|
}
|
|
1647
|
-
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
1648
|
-
if (!isBigCommerceCustomerLoggedIn(checkout)) {
|
|
1590
|
+
const checkout = await localization.fetchBigCommerceCheckout(checkoutId);
|
|
1591
|
+
if (!localization.isBigCommerceCustomerLoggedIn(checkout)) {
|
|
1649
1592
|
return;
|
|
1650
1593
|
}
|
|
1651
1594
|
const addresses = getBigCommerceCustomerAddresses(checkout, {
|