@zonos/elements 1.3.268 → 1.3.269
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-87fbbb5a.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-0fa6e022.js → hasInclusivePrice-c86ed1f5.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-c2e3f232.js → invoice-952f32c4.js} +2 -2
- package/dist/cjs/{isCollectMobileTablet-6014787b.js → isCollectMobileTablet-1cb21c59.js} +2 -2
- package/dist/cjs/{localization-f897bc45.js → localization-a969f224.js} +239 -2
- package/dist/cjs/{paypal-6756a0da.js → paypal-cfe1e8e9.js} +2 -2
- package/dist/cjs/{placeTestOrder-a4874e51.js → placeTestOrder-613878fb.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-584d50fe.js → renderCheckoutCurrency-5a333d29.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/shouldShowHelloWidget.js +61 -0
- package/dist/collection/utils/toggleBigcommerceNativeCurrencySelector.js +2 -1
- package/dist/esm/{cart-68c16805.js → cart-663ef7d5.js} +1 -1
- package/dist/esm/{hasInclusivePrice-f1ca1610.js → hasInclusivePrice-f8bd057d.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-d0eadc6a.js → invoice-db7211a6.js} +2 -2
- package/dist/esm/{isCollectMobileTablet-11ade63f.js → isCollectMobileTablet-24c912b1.js} +2 -2
- package/dist/esm/{localization-8e81b696.js → localization-dc19e8bb.js} +236 -3
- package/dist/esm/{paypal-e32877e9.js → paypal-cdbe69ef.js} +2 -2
- package/dist/esm/{placeTestOrder-4cf429d7.js → placeTestOrder-ba67e208.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-9459b8a3.js → renderCheckoutCurrency-fb1cbd28.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-663ef7d5.js} +1 -1
- package/dist/esm-es5/{hasInclusivePrice-f1ca1610.js → hasInclusivePrice-f8bd057d.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-d0eadc6a.js → invoice-db7211a6.js} +1 -1
- package/dist/esm-es5/{isCollectMobileTablet-11ade63f.js → isCollectMobileTablet-24c912b1.js} +1 -1
- package/dist/esm-es5/{localization-8e81b696.js → localization-dc19e8bb.js} +1 -1
- package/dist/esm-es5/{paypal-e32877e9.js → paypal-cdbe69ef.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-4cf429d7.js → placeTestOrder-ba67e208.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-9459b8a3.js → renderCheckoutCurrency-fb1cbd28.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-50362897.entry.js → p-049fc407.entry.js} +1 -1
- package/dist/zonos-elements/{p-c7ca3e98.system.entry.js → p-0581cfc9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-01913da8.js → p-097d7819.js} +1 -1
- package/dist/zonos-elements/{p-5e18d92b.system.entry.js → p-09d32e53.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-8ddc21f1.system.entry.js → p-0daed059.system.entry.js} +1 -1
- package/dist/zonos-elements/p-1bde60d5.system.entry.js +1 -0
- package/dist/zonos-elements/{p-dcafbd4e.js → p-243dda5f.js} +1 -1
- package/dist/zonos-elements/p-263d14da.system.entry.js +1 -0
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/p-2be4335f.js +1 -0
- package/dist/zonos-elements/{p-64e8f05d.system.entry.js → p-33a37c42.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-17e3cd62.js → p-44147850.js} +1 -1
- package/dist/zonos-elements/{p-97da66f2.entry.js → p-488c1af1.entry.js} +1 -1
- package/dist/zonos-elements/{p-95b460e9.system.entry.js → p-48ec0b61.system.entry.js} +1 -1
- package/dist/zonos-elements/p-4af88255.entry.js +1 -0
- package/dist/zonos-elements/p-4b6e367d.system.js +1 -0
- package/dist/zonos-elements/{p-7fef8558.entry.js → p-513e8278.entry.js} +1 -1
- package/dist/zonos-elements/p-56711a61.js +1 -0
- package/dist/zonos-elements/{p-e3d6f9b4.entry.js → p-57b55808.entry.js} +1 -1
- package/dist/zonos-elements/p-57c3c68f.entry.js +1 -0
- package/dist/zonos-elements/{p-c3459f4a.entry.js → p-680da401.entry.js} +1 -1
- package/dist/zonos-elements/p-699276f2.system.js +1 -0
- package/dist/zonos-elements/{p-a0ee01dd.system.entry.js → p-71528303.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-44b279cc.system.js → p-7662d32a.system.js} +1 -1
- package/dist/zonos-elements/{p-48805ed6.system.entry.js → p-82ce355d.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-620a9013.entry.js → p-84d4f04d.entry.js} +1 -1
- package/dist/zonos-elements/{p-673407b8.entry.js → p-858103a0.entry.js} +1 -1
- package/dist/zonos-elements/{p-bc9a30a1.system.entry.js → p-882fb843.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-24091606.system.entry.js → p-8a24701c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-593764cf.system.entry.js → p-8f0bdb87.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-4fe3d5e0.system.js → p-8f817a47.system.js} +1 -1
- package/dist/zonos-elements/{p-38311c16.entry.js → p-9092f655.entry.js} +1 -1
- package/dist/zonos-elements/{p-6f41c193.entry.js → p-9377b5c2.entry.js} +1 -1
- package/dist/zonos-elements/{p-b93b66c2.entry.js → p-9799193c.entry.js} +1 -1
- package/dist/zonos-elements/{p-fc5007e0.entry.js → p-9a509268.entry.js} +1 -1
- package/dist/zonos-elements/{p-69089a6f.system.entry.js → p-9ea67d63.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7166df08.entry.js → p-a237429e.entry.js} +1 -1
- package/dist/zonos-elements/{p-1eef8c23.system.js → p-a3a79b2f.system.js} +1 -1
- package/dist/zonos-elements/p-accccb9c.entry.js +1 -0
- package/dist/zonos-elements/{p-623fc89a.system.entry.js → p-b0ed0fe7.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7628569a.entry.js → p-ba127f51.entry.js} +1 -1
- package/dist/zonos-elements/{p-72c3756a.js → p-bbef037c.js} +1 -1
- package/dist/zonos-elements/p-be64a52e.entry.js +1 -0
- package/dist/zonos-elements/{p-5b05b461.system.js → p-c2023a08.system.js} +1 -1
- package/dist/zonos-elements/{p-1376e67f.system.entry.js → p-c4ef873a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-774de1ec.system.js → p-c5caf47b.system.js} +1 -1
- package/dist/zonos-elements/{p-108b5307.system.entry.js → p-c62293d5.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-b71ef46e.js → p-cd5444b0.js} +1 -1
- package/dist/zonos-elements/p-d437bc28.js +1 -0
- package/dist/zonos-elements/{p-2ccd20c0.system.js → p-d932973f.system.js} +1 -1
- package/dist/zonos-elements/{p-95f3bbad.system.entry.js → p-df0c8fb6.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-c91fade3.entry.js → p-e05e5825.entry.js} +1 -1
- package/dist/zonos-elements/{p-53a59935.system.js → p-f5684fc2.system.js} +1 -1
- package/dist/zonos-elements/{p-af12a1b7.system.entry.js → p-fc270539.system.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-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-5fa2395d.system.js +0 -1
- package/dist/zonos-elements/p-72960738.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
|
@@ -17182,6 +17182,229 @@ const getShippingZones = async () => {
|
|
|
17182
17182
|
return shippingZones || null;
|
|
17183
17183
|
};
|
|
17184
17184
|
|
|
17185
|
+
/**
|
|
17186
|
+
* Fetch the checkout/cart ID from the BigCommerce Storefront Cart API.
|
|
17187
|
+
* The `/checkout` page URL does not include the checkout ID, so we
|
|
17188
|
+
* retrieve it from `/api/storefront/cart` which returns the active cart(s).
|
|
17189
|
+
*/
|
|
17190
|
+
const fetchCheckoutId = async () => {
|
|
17191
|
+
var _a, _b;
|
|
17192
|
+
try {
|
|
17193
|
+
const response = await fetch('/api/storefront/cart', {
|
|
17194
|
+
credentials: 'same-origin',
|
|
17195
|
+
headers: {
|
|
17196
|
+
Accept: 'application/json',
|
|
17197
|
+
},
|
|
17198
|
+
});
|
|
17199
|
+
if (!response.ok) {
|
|
17200
|
+
log(`Failed to fetch BigCommerce cart: ${String(response.status)}`, 'error');
|
|
17201
|
+
return null;
|
|
17202
|
+
}
|
|
17203
|
+
const carts = (await response.json());
|
|
17204
|
+
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;
|
|
17205
|
+
}
|
|
17206
|
+
catch (error) {
|
|
17207
|
+
logError('Error fetching BigCommerce cart data', error);
|
|
17208
|
+
return null;
|
|
17209
|
+
}
|
|
17210
|
+
};
|
|
17211
|
+
/**
|
|
17212
|
+
* Fetch checkout data from the BigCommerce Storefront API.
|
|
17213
|
+
* This API is cookie-authenticated (same-origin), so no token is needed.
|
|
17214
|
+
*/
|
|
17215
|
+
const fetchBigCommerceCheckout = async (checkoutId) => {
|
|
17216
|
+
try {
|
|
17217
|
+
const response = await fetch(`/api/storefront/checkouts/${checkoutId}?include=customer.customerGroup,customer.addresses`, {
|
|
17218
|
+
credentials: 'same-origin',
|
|
17219
|
+
headers: {
|
|
17220
|
+
Accept: 'application/json',
|
|
17221
|
+
'Content-Type': 'application/json',
|
|
17222
|
+
},
|
|
17223
|
+
});
|
|
17224
|
+
if (!response.ok) {
|
|
17225
|
+
log(`Failed to fetch BigCommerce checkout: ${String(response.status)}`, 'error');
|
|
17226
|
+
return null;
|
|
17227
|
+
}
|
|
17228
|
+
return (await response.json());
|
|
17229
|
+
}
|
|
17230
|
+
catch (error) {
|
|
17231
|
+
logError('Error fetching BigCommerce checkout data', error);
|
|
17232
|
+
return null;
|
|
17233
|
+
}
|
|
17234
|
+
};
|
|
17235
|
+
/**
|
|
17236
|
+
* Delete a consignment (a saved shipping selection, e.g. a domestic shipping
|
|
17237
|
+
* quote the shopper added on the cart page) from the active BigCommerce
|
|
17238
|
+
* checkout via the Storefront API. Cookie-authenticated (same-origin), so no
|
|
17239
|
+
* token is needed. Returns the updated checkout on success, or null on
|
|
17240
|
+
* failure.
|
|
17241
|
+
*/
|
|
17242
|
+
const deleteBigCommerceConsignment = async (checkoutId, consignmentId) => {
|
|
17243
|
+
try {
|
|
17244
|
+
const response = await fetch(`/api/storefront/checkouts/${checkoutId}/consignments/${consignmentId}`, {
|
|
17245
|
+
credentials: 'same-origin',
|
|
17246
|
+
headers: {
|
|
17247
|
+
Accept: 'application/json',
|
|
17248
|
+
'Content-Type': 'application/json',
|
|
17249
|
+
},
|
|
17250
|
+
method: 'DELETE',
|
|
17251
|
+
});
|
|
17252
|
+
if (!response.ok) {
|
|
17253
|
+
log(`Failed to delete BigCommerce consignment: ${String(response.status)}`, 'error');
|
|
17254
|
+
return null;
|
|
17255
|
+
}
|
|
17256
|
+
return (await response.json());
|
|
17257
|
+
}
|
|
17258
|
+
catch (error) {
|
|
17259
|
+
logError('Error deleting BigCommerce consignment', error);
|
|
17260
|
+
return null;
|
|
17261
|
+
}
|
|
17262
|
+
};
|
|
17263
|
+
/**
|
|
17264
|
+
* Whether the BigCommerce shopper is already logged in. We key off the
|
|
17265
|
+
* customer's numeric `id` since the storefront API populates it only for
|
|
17266
|
+
* authenticated sessions (guest checkouts have an empty `customer` object).
|
|
17267
|
+
*/
|
|
17268
|
+
const isBigCommerceCustomerLoggedIn = (checkout) => { var _a; return !!((_a = checkout === null || checkout === void 0 ? void 0 : checkout.customer) === null || _a === void 0 ? void 0 : _a.id); };
|
|
17269
|
+
|
|
17270
|
+
/**
|
|
17271
|
+
* Whether the Hello widget should be shown for the current shopper. This is the
|
|
17272
|
+
* single source of truth for Hello's visibility decision — the `zonos-hello`
|
|
17273
|
+
* component renders by it, and other features (e.g. BigCommerce cart shipping
|
|
17274
|
+
* cleanup) gate on it so their behavior stays in lockstep with what the shopper
|
|
17275
|
+
* actually sees.
|
|
17276
|
+
*
|
|
17277
|
+
* Resolves the configured `widgetVisibility` behavior (with the deprecated
|
|
17278
|
+
* `showForCountries` override) against the selected country and shipping-zone
|
|
17279
|
+
* state, then applies the include/exclude country overrides.
|
|
17280
|
+
*
|
|
17281
|
+
* @param showLog - emit a debug log when the shopper is not in a shipping zone.
|
|
17282
|
+
* Defaults to `true`; pass `false` from non-rendering callers to avoid log
|
|
17283
|
+
* noise.
|
|
17284
|
+
*/
|
|
17285
|
+
const shouldShowHelloWidget = (showLog = true) => {
|
|
17286
|
+
var _a, _b;
|
|
17287
|
+
if (!localizationStore.localizationLoaded) {
|
|
17288
|
+
return false;
|
|
17289
|
+
}
|
|
17290
|
+
const { countryDisplayRules, showForCountries } = zonosStore.helloSettings;
|
|
17291
|
+
const visibilityRules = countryDisplayRules === null || countryDisplayRules === void 0 ? void 0 : countryDisplayRules.widgetVisibility;
|
|
17292
|
+
const selectedCountry = localizationStore.selectedCountryCode;
|
|
17293
|
+
// Resolve behavior: deprecated showForCountries overrides widgetVisibility.behavior
|
|
17294
|
+
// If showForCountries is an array of country codes, treat as legacy explicit list
|
|
17295
|
+
const behavior = Array.isArray(showForCountries)
|
|
17296
|
+
? showForCountries
|
|
17297
|
+
: (showForCountries !== null && showForCountries !== void 0 ? showForCountries : visibilityRules === null || visibilityRules === void 0 ? void 0 : visibilityRules.behavior);
|
|
17298
|
+
if (showLog && !localizationStore.isShippableCountry) {
|
|
17299
|
+
log(`Hello: not shippable country - Show for countries: ${behavior}`);
|
|
17300
|
+
}
|
|
17301
|
+
// Legacy: explicit list of country codes from deprecated showForCountries
|
|
17302
|
+
if (Array.isArray(behavior)) {
|
|
17303
|
+
return !!selectedCountry && behavior.includes(selectedCountry);
|
|
17304
|
+
}
|
|
17305
|
+
// Determine base visibility from behavior
|
|
17306
|
+
let isVisible;
|
|
17307
|
+
if (behavior === 'ALL') {
|
|
17308
|
+
isVisible = true;
|
|
17309
|
+
}
|
|
17310
|
+
else {
|
|
17311
|
+
// Default: ONLY_SHIPPABLE
|
|
17312
|
+
isVisible = localizationStore.isShippableCountry;
|
|
17313
|
+
}
|
|
17314
|
+
// Apply includedCountries — force show the widget for these countries
|
|
17315
|
+
if (!isVisible &&
|
|
17316
|
+
selectedCountry &&
|
|
17317
|
+
((_a = visibilityRules === null || visibilityRules === void 0 ? void 0 : visibilityRules.includedCountries) === null || _a === void 0 ? void 0 : _a.includes(selectedCountry))) {
|
|
17318
|
+
isVisible = true;
|
|
17319
|
+
}
|
|
17320
|
+
// Apply excludedCountries — force hide the widget for these countries
|
|
17321
|
+
if (isVisible &&
|
|
17322
|
+
selectedCountry &&
|
|
17323
|
+
((_b = visibilityRules === null || visibilityRules === void 0 ? void 0 : visibilityRules.excludedCountries) === null || _b === void 0 ? void 0 : _b.includes(selectedCountry))) {
|
|
17324
|
+
isVisible = false;
|
|
17325
|
+
}
|
|
17326
|
+
return isVisible;
|
|
17327
|
+
};
|
|
17328
|
+
|
|
17329
|
+
/**
|
|
17330
|
+
* Guard against overlapping passes. `removeBigcommerceCartShipping` is fired on
|
|
17331
|
+
* every country change; without this flag, rapid country switches could stack
|
|
17332
|
+
* concurrent fetch/DELETE cycles against the same cart before the reload kicks
|
|
17333
|
+
* in.
|
|
17334
|
+
*/
|
|
17335
|
+
let isRemoving = false;
|
|
17336
|
+
/**
|
|
17337
|
+
* On the BigCommerce cart page, drop any native domestic shipping quote the
|
|
17338
|
+
* shopper added before they switched to an international country, then reload
|
|
17339
|
+
* the page.
|
|
17340
|
+
*
|
|
17341
|
+
* The native cart stores a shipping estimate as a consignment on the active
|
|
17342
|
+
* checkout. When Hello is shown the shopper is checking out internationally
|
|
17343
|
+
* through Zonos, so that domestic shipping cost should not linger in the Grand
|
|
17344
|
+
* Total. We delete the consignment(s) and reload so the server re-renders the
|
|
17345
|
+
* cart consistently (subtotal, shipping, and Grand Total all add up).
|
|
17346
|
+
*
|
|
17347
|
+
* No-ops unless all of the following hold: the host is BigCommerce, the shopper
|
|
17348
|
+
* is on the cart page, they are in a shipping zone with Hello shown, and the
|
|
17349
|
+
* active checkout actually has a consignment. Because the reload happens only
|
|
17350
|
+
* when a consignment is found and removed, the freshly-loaded page has none —
|
|
17351
|
+
* so this cannot loop.
|
|
17352
|
+
*/
|
|
17353
|
+
const removeBigcommerceCartShipping = async () => {
|
|
17354
|
+
var _a, _b;
|
|
17355
|
+
if (typeof window === 'undefined' || !((_a = window.Zonos) === null || _a === void 0 ? void 0 : _a.isBigCommerce)) {
|
|
17356
|
+
return;
|
|
17357
|
+
}
|
|
17358
|
+
// Only on the cart page and only when Hello is shown — elsewhere there is no
|
|
17359
|
+
// Grand Total to correct. Gate on Hello visibility (not raw shipping-zone
|
|
17360
|
+
// membership) so include/exclude country overrides are respected.
|
|
17361
|
+
if (window.location.pathname !== '/cart.php' ||
|
|
17362
|
+
!localizationStore.isShippableCountry ||
|
|
17363
|
+
!shouldShowHelloWidget(false)) {
|
|
17364
|
+
return;
|
|
17365
|
+
}
|
|
17366
|
+
if (isRemoving) {
|
|
17367
|
+
return;
|
|
17368
|
+
}
|
|
17369
|
+
isRemoving = true;
|
|
17370
|
+
try {
|
|
17371
|
+
const checkoutId = await fetchCheckoutId();
|
|
17372
|
+
if (!checkoutId) {
|
|
17373
|
+
return;
|
|
17374
|
+
}
|
|
17375
|
+
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
17376
|
+
const consignmentIds = ((_b = checkout === null || checkout === void 0 ? void 0 : checkout.consignments) !== null && _b !== void 0 ? _b : [])
|
|
17377
|
+
.map(consignment => consignment.id)
|
|
17378
|
+
.filter((id) => !!id);
|
|
17379
|
+
// Nothing to do if there is no domestic shipping quote on the cart.
|
|
17380
|
+
if (!consignmentIds.length) {
|
|
17381
|
+
return;
|
|
17382
|
+
}
|
|
17383
|
+
log(`Removing ${String(consignmentIds.length)} BigCommerce cart consignment(s) for international shopper`, 'info');
|
|
17384
|
+
// `deleteBigCommerceConsignment` resolves to null on failure (it swallows
|
|
17385
|
+
// the error and logs it), so a non-null result means that consignment was
|
|
17386
|
+
// actually removed.
|
|
17387
|
+
const deleteResults = await Promise.all(consignmentIds.map(consignmentId => deleteBigCommerceConsignment(checkoutId, consignmentId)));
|
|
17388
|
+
const removedCount = deleteResults.filter(Boolean).length;
|
|
17389
|
+
// Only reload when at least one consignment was actually removed. If every
|
|
17390
|
+
// DELETE failed, reloading would re-run this on init with the same
|
|
17391
|
+
// consignments still present and trap the shopper in a reload loop.
|
|
17392
|
+
if (!removedCount) {
|
|
17393
|
+
log('No BigCommerce cart consignments were removed; skipping reload to avoid a reload loop', 'warn');
|
|
17394
|
+
return;
|
|
17395
|
+
}
|
|
17396
|
+
// Reload so the server re-renders the cart consistently without the removed
|
|
17397
|
+
// shipping, instead of surgically patching the DOM total.
|
|
17398
|
+
window.location.reload();
|
|
17399
|
+
}
|
|
17400
|
+
catch (error) {
|
|
17401
|
+
logError('Error removing BigCommerce cart shipping consignment', error);
|
|
17402
|
+
}
|
|
17403
|
+
finally {
|
|
17404
|
+
isRemoving = false;
|
|
17405
|
+
}
|
|
17406
|
+
};
|
|
17407
|
+
|
|
17185
17408
|
const applyInclusiveEffectiveRate = (amount) => {
|
|
17186
17409
|
const inclusivePrice = localizationStore.inclusivePricingConfigurations.find(x => x.shipToCountry === localizationStore.selectedCountryCode);
|
|
17187
17410
|
if (!inclusivePrice) {
|
|
@@ -17572,7 +17795,7 @@ const toggleBigcommerceNativeCurrencySelector = () => {
|
|
|
17572
17795
|
return;
|
|
17573
17796
|
}
|
|
17574
17797
|
const bigcommerceCurrencyCode = document.body.dataset.currencyCode;
|
|
17575
|
-
const shouldHide = localizationStore.isShippableCountry &&
|
|
17798
|
+
const shouldHide = (shouldShowHelloWidget(false) || localizationStore.isShippableCountry) &&
|
|
17576
17799
|
!!bigcommerceCurrencyCode &&
|
|
17577
17800
|
bigcommerceCurrencyCode === zonosStore.sourceCurrency;
|
|
17578
17801
|
try {
|
|
@@ -17757,6 +17980,11 @@ const localizationStoreUpdateSelectedCountryCode = ({ isInitializing, newSelecte
|
|
|
17757
17980
|
// because `currencyDisplay` is also invoked from the price-mutation
|
|
17758
17981
|
// observer in `zonos-hello.tsx`, which fires on every DOM render.
|
|
17759
17982
|
toggleBigcommerceNativeCurrencySelector();
|
|
17983
|
+
// On the BigCommerce cart page, drop any native domestic shipping quote the
|
|
17984
|
+
// shopper added before switching to an international country so the Grand
|
|
17985
|
+
// Total reflects only subtotal + coupon. No-ops off-cart, off-BigCommerce,
|
|
17986
|
+
// for non-shippable countries, or when the cart has no consignment.
|
|
17987
|
+
void removeBigcommerceCartShipping();
|
|
17760
17988
|
if (!selectedCountryCode) {
|
|
17761
17989
|
return;
|
|
17762
17990
|
}
|
|
@@ -17934,7 +18162,12 @@ const initLocalizationStore = async () => {
|
|
|
17934
18162
|
newSelectedCountryCode: 'CA',
|
|
17935
18163
|
});
|
|
17936
18164
|
}
|
|
17937
|
-
localizationStore.localizationLoaded
|
|
18165
|
+
if (!localizationStore.localizationLoaded) {
|
|
18166
|
+
localizationStore.localizationLoaded = true;
|
|
18167
|
+
void removeBigcommerceCartShipping();
|
|
18168
|
+
// shouldShowHelloWidget is false because localization is not loaded yet
|
|
18169
|
+
void toggleBigcommerceNativeCurrencySelector();
|
|
18170
|
+
}
|
|
17938
18171
|
};
|
|
17939
18172
|
|
|
17940
|
-
export { VARIANT_TEST_KEY_EXPIRATION as V,
|
|
18173
|
+
export { VARIANT_TEST_KEY_EXPIRATION as V, fetchCheckoutId as a, fetchBigCommerceCheckout as b, localizationStoreUpdateSelectedCountryCode as c, storageStoreSetEnabledVariantTestKeys as d, localizationStoreOnChange as e, filterValidTests as f, getZCountryUrlParam as g, currencyFormat as h, isBigCommerceCustomerLoggedIn as i, getOverridenZCountry as j, isValidSelector as k, localizationStore as l, initLocalizationStore as m, setZCountryUrlParam as n, currencyDisplay as o, currencyConvertAndFormat as p, currencyConvert as q, shouldShowHelloWidget as r, storageStore as s, translate as t, applyInclusiveEffectiveRate as u, translationStoreOnChange as v, storageStoreOnChange as w, getFallbackDefaultCountryCode as x, localizationStoreUpdateSelectedLocale as y };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z as zonosStore, c as createStore } from './zonosStore-8e19daff.js';
|
|
2
|
-
import { t as trackConversionEvent, v as isPolicyConsentRequired, E as policyConsentStore, A as validateCheckoutSession, b as stripeStore, d as cartStore, x as stripeStoreHandleInventoryCheck, y as storeCreditStoreApplyCredit, J as stripeStoreRecordPolicyConsent, z as storeCreditStoreCoversFullAmount, B as storeCreditStoreCreateOrder, u as cartStoreNextStep, h as cartStoreClearCheckoutInterval, I as storeCreditStoreGetEffectiveAmount } from './cart-
|
|
3
|
-
import { t as translate, s as storageStore } from './localization-
|
|
2
|
+
import { t as trackConversionEvent, v as isPolicyConsentRequired, E as policyConsentStore, A as validateCheckoutSession, b as stripeStore, d as cartStore, x as stripeStoreHandleInventoryCheck, y as storeCreditStoreApplyCredit, J as stripeStoreRecordPolicyConsent, z as storeCreditStoreCoversFullAmount, B as storeCreditStoreCreateOrder, u as cartStoreNextStep, h as cartStoreClearCheckoutInterval, I as storeCreditStoreGetEffectiveAmount } from './cart-663ef7d5.js';
|
|
3
|
+
import { t as translate, s as storageStore } from './localization-dc19e8bb.js';
|
|
4
4
|
import { h as handleFetch, g as getIsTestMode, l as logError, j as jsonParse } from './handleFetch-a844cac1.js';
|
|
5
5
|
import { i as isContrastColor } from './isContrastColor-fbddacb6.js';
|
|
6
6
|
import { l as log } from './VarianceTest-572cecf5.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as cartStore } from './cart-
|
|
2
|
-
import { s as storageStore } from './localization-
|
|
1
|
+
import { d as cartStore } from './cart-663ef7d5.js';
|
|
2
|
+
import { s as storageStore } from './localization-dc19e8bb.js';
|
|
3
3
|
import { l as logError, h as handleFetch } from './handleFetch-a844cac1.js';
|
|
4
4
|
|
|
5
5
|
const placeTestOrder = async () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as cartStore } from './cart-
|
|
2
|
-
import {
|
|
1
|
+
import { d as cartStore } from './cart-663ef7d5.js';
|
|
2
|
+
import { u as applyInclusiveEffectiveRate, h as currencyFormat } from './localization-dc19e8bb.js';
|
|
3
3
|
|
|
4
4
|
const getDisplayCurrency = () => {
|
|
5
5
|
var _a, _b;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, h, a as Host, d as createEvent, g as getElement } from './index-cfd394c8.js';
|
|
2
|
-
import { t as translate, l as localizationStore, s as storageStore,
|
|
2
|
+
import { t as translate, l as localizationStore, s as storageStore, w as storageStoreOnChange } from './localization-dc19e8bb.js';
|
|
3
3
|
import { i as isTextContainsNonLatinChars, c as containsNonLatinChars } from './containsNonLatinChars-2d8810c3.js';
|
|
4
|
-
import { U as extractName, b as stripeStore, r as stripeStorePrefetchLandedCost, t as trackConversionEvent } from './cart-
|
|
4
|
+
import { U as extractName, b as stripeStore, r as stripeStorePrefetchLandedCost, t as trackConversionEvent } from './cart-663ef7d5.js';
|
|
5
5
|
import { c as classes } from './classes-0d95c529.js';
|
|
6
6
|
import { g as getBorderRadius } from './getBorderRadius-d23f47a6.js';
|
|
7
7
|
import { z as zonosStore, f as zonosStoreFontFamily } from './zonosStore-8e19daff.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as registerInstance, d as createEvent, h, a as Host, g as getElement } from './index-cfd394c8.js';
|
|
2
2
|
import { t as throttle_1 } from './throttle-f09d0659.js';
|
|
3
|
-
import { b as stripeStore, t as trackConversionEvent, U as extractName, H as stripeStoreOnChange, r as stripeStorePrefetchLandedCost, d as cartStore } from './cart-
|
|
4
|
-
import { s as storageStore,
|
|
3
|
+
import { b as stripeStore, t as trackConversionEvent, U as extractName, H as stripeStoreOnChange, r as stripeStorePrefetchLandedCost, d as cartStore } from './cart-663ef7d5.js';
|
|
4
|
+
import { s as storageStore, x as getFallbackDefaultCountryCode, t as translate, w as storageStoreOnChange, l as localizationStore } from './localization-dc19e8bb.js';
|
|
5
5
|
import { z as zonosStore, g as getZonosStoreTheme, f as zonosStoreFontFamily } from './zonosStore-8e19daff.js';
|
|
6
6
|
import { l as logError, i as isCheckoutMobile, s as sendErrorLog } from './handleFetch-a844cac1.js';
|
|
7
7
|
import { a as shouldRenderTaxIdInput, s as shouldRenderShortAddressCodeInput } from './shouldRenderTaxIdInput-2572bf77.js';
|
|
@@ -2,10 +2,10 @@ import { r as registerInstance, h, a as Host, g as getElement, d as createEvent
|
|
|
2
2
|
import { f as zonosStoreFontFamily } from './zonosStore-8e19daff.js';
|
|
3
3
|
import { c as classes } from './classes-0d95c529.js';
|
|
4
4
|
import { g as getBorderRadius } from './getBorderRadius-d23f47a6.js';
|
|
5
|
-
import { b as stripeStore, t as trackConversionEvent } from './cart-
|
|
6
|
-
import { s as storageStore } from './localization-
|
|
5
|
+
import { b as stripeStore, t as trackConversionEvent } from './cart-663ef7d5.js';
|
|
6
|
+
import { s as storageStore } from './localization-dc19e8bb.js';
|
|
7
7
|
import { l as logError } from './handleFetch-a844cac1.js';
|
|
8
|
-
import { d as paypalStoreInitButtons, e as paypalStoreOnChange } from './paypal-
|
|
8
|
+
import { d as paypalStoreInitButtons, e as paypalStoreOnChange } from './paypal-cdbe69ef.js';
|
|
9
9
|
import { l as log } from './VarianceTest-572cecf5.js';
|
|
10
10
|
import './isDarkColor-566f04c5.js';
|
|
11
11
|
import './isContrastColor-fbddacb6.js';
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { r as registerInstance, e as getAssetPath, h, a as Host, F as Fragment, d as createEvent, g as getElement } from './index-cfd394c8.js';
|
|
2
|
-
import { d as cartStore, M as cartStoreHasOneEligibleItem, N as stripeStoreApplyPromoCode, O as stripeStoreRemovePromoCode, b as stripeStore, F as stripeStoreReset, c as stripeStoreRetrievePayment, t as trackConversionEvent, P as stripeStoreResetPromoCode, Q as stripeStoreMessageBasedOnStatus, R as storeCreditStore, S as storeCreditStoreReset, z as storeCreditStoreCoversFullAmount, v as isPolicyConsentRequired, E as policyConsentStore, J as stripeStoreRecordPolicyConsent, u as cartStoreNextStep, T as stripeStoreTranslateAddressToLatin, U as extractName, G as cartStoreOnChange, V as stripeStoreAsyncAddressUpdate, L as cartStoreUpdateSelectedShippingOption, W as cartStoreGetShippingTransitInfo, X as cartStoreGetMethod, Y as sortServiceLevelOptionsByAmount } from './cart-
|
|
3
|
-
import { t as translate, l as localizationStore, s as storageStore,
|
|
4
|
-
import { r as renderCheckoutCurrency } from './renderCheckoutCurrency-
|
|
2
|
+
import { d as cartStore, M as cartStoreHasOneEligibleItem, N as stripeStoreApplyPromoCode, O as stripeStoreRemovePromoCode, b as stripeStore, F as stripeStoreReset, c as stripeStoreRetrievePayment, t as trackConversionEvent, P as stripeStoreResetPromoCode, Q as stripeStoreMessageBasedOnStatus, R as storeCreditStore, S as storeCreditStoreReset, z as storeCreditStoreCoversFullAmount, v as isPolicyConsentRequired, E as policyConsentStore, J as stripeStoreRecordPolicyConsent, u as cartStoreNextStep, T as stripeStoreTranslateAddressToLatin, U as extractName, G as cartStoreOnChange, V as stripeStoreAsyncAddressUpdate, L as cartStoreUpdateSelectedShippingOption, W as cartStoreGetShippingTransitInfo, X as cartStoreGetMethod, Y as sortServiceLevelOptionsByAmount } from './cart-663ef7d5.js';
|
|
3
|
+
import { t as translate, l as localizationStore, s as storageStore, e as localizationStoreOnChange } from './localization-dc19e8bb.js';
|
|
4
|
+
import { r as renderCheckoutCurrency } from './renderCheckoutCurrency-fb1cbd28.js';
|
|
5
5
|
import { c as cleanHtmlMarkdown } from './cleanHtmlMarkdown-5f7856f2.js';
|
|
6
6
|
import { c as classes } from './classes-0d95c529.js';
|
|
7
7
|
import { z as zonosStore, h as zonosStoreOnChange, g as getZonosStoreTheme, f as zonosStoreFontFamily } from './zonosStore-8e19daff.js';
|
|
8
|
-
import { D as DUTY_KEY, T as TAXES_KEY, h as hasInclusivePrice } from './hasInclusivePrice-
|
|
9
|
-
import { s as submitAnalytics, c as paypalStoreReset, a as paypalStore } from './paypal-
|
|
8
|
+
import { D as DUTY_KEY, T as TAXES_KEY, h as hasInclusivePrice } from './hasInclusivePrice-f8bd057d.js';
|
|
9
|
+
import { s as submitAnalytics, c as paypalStoreReset, a as paypalStore } from './paypal-cdbe69ef.js';
|
|
10
10
|
import { h as handleFetch, s as sendErrorLog, j as jsonParse, g as getIsTestMode, i as isCheckoutMobile, a as getIsStagingMode } from './handleFetch-a844cac1.js';
|
|
11
11
|
import { c as createCustomEvent } from './createCustomEvent-58159025.js';
|
|
12
12
|
import { g as getBorderRadius } from './getBorderRadius-d23f47a6.js';
|
|
13
13
|
import { l as log, b as allLogs } from './VarianceTest-572cecf5.js';
|
|
14
14
|
import { l as languages } from './ILanguage-cd6acb72.js';
|
|
15
|
-
import { p as placeTestOrder } from './placeTestOrder-
|
|
15
|
+
import { p as placeTestOrder } from './placeTestOrder-ba67e208.js';
|
|
16
16
|
import { i as isDarkColor } from './isDarkColor-566f04c5.js';
|
|
17
17
|
import { g as getContrastColor } from './getContrastColor-f0bd5b65.js';
|
|
18
18
|
import { i as isColorVariable } from './isColorVariable-0a94004f.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { r as registerInstance, h, F as Fragment, a as Host } from './index-cfd394c8.js';
|
|
2
|
-
import { s as stripeStoreGetDomesticShippingSession, a as stripeStoreSaveDomesticShippingSession, b as stripeStore, i as initStripeElements, c as stripeStoreRetrievePayment, d as cartStore, e as cartStoreUpdateItems, f as cartStoreReset, p as policyConsentStoreReset, g as cartStoreResetTabItems, h as cartStoreClearCheckoutInterval, j as stripeStoreInitCheckoutSession, k as stripeStoreGetPaymentIntent, l as cartStoreStartCheckoutInterval, t as trackConversionEvent, m as getCheckoutSessionBody, n as cartStoreUpdateToErrorState, o as stripeStoreCleanupDomesticShippingSession, q as cartStoreSetCheckoutSession, r as stripeStorePrefetchLandedCost, u as cartStoreNextStep, v as isPolicyConsentRequired, w as stripeStoreUpdateCheckoutSessionBaseCurrency, x as stripeStoreHandleInventoryCheck, y as storeCreditStoreApplyCredit, z as storeCreditStoreCoversFullAmount, A as validateCheckoutSession, B as storeCreditStoreCreateOrder, C as stripeStoreConfirmPayment, D as stripeStoreHandleInventoryRefund, E as policyConsentStore, F as stripeStoreReset, G as cartStoreOnChange, H as stripeStoreOnChange, I as storeCreditStoreGetEffectiveAmount } from './cart-
|
|
3
|
-
import { p as paypalStoreHasPaypalEnabled, s as submitAnalytics, a as paypalStore, b as paypalInitScript } from './paypal-
|
|
4
|
-
import { f as filterValidTests, l as localizationStore,
|
|
2
|
+
import { s as stripeStoreGetDomesticShippingSession, a as stripeStoreSaveDomesticShippingSession, b as stripeStore, i as initStripeElements, c as stripeStoreRetrievePayment, d as cartStore, e as cartStoreUpdateItems, f as cartStoreReset, p as policyConsentStoreReset, g as cartStoreResetTabItems, h as cartStoreClearCheckoutInterval, j as stripeStoreInitCheckoutSession, k as stripeStoreGetPaymentIntent, l as cartStoreStartCheckoutInterval, t as trackConversionEvent, m as getCheckoutSessionBody, n as cartStoreUpdateToErrorState, o as stripeStoreCleanupDomesticShippingSession, q as cartStoreSetCheckoutSession, r as stripeStorePrefetchLandedCost, u as cartStoreNextStep, v as isPolicyConsentRequired, w as stripeStoreUpdateCheckoutSessionBaseCurrency, x as stripeStoreHandleInventoryCheck, y as storeCreditStoreApplyCredit, z as storeCreditStoreCoversFullAmount, A as validateCheckoutSession, B as storeCreditStoreCreateOrder, C as stripeStoreConfirmPayment, D as stripeStoreHandleInventoryRefund, E as policyConsentStore, F as stripeStoreReset, G as cartStoreOnChange, H as stripeStoreOnChange, I as storeCreditStoreGetEffectiveAmount } from './cart-663ef7d5.js';
|
|
3
|
+
import { p as paypalStoreHasPaypalEnabled, s as submitAnalytics, a as paypalStore, b as paypalInitScript } from './paypal-cdbe69ef.js';
|
|
4
|
+
import { f as filterValidTests, a as fetchCheckoutId, b as fetchBigCommerceCheckout, i as isBigCommerceCustomerLoggedIn, l as localizationStore, c as localizationStoreUpdateSelectedCountryCode, g as getZCountryUrlParam, s as storageStore, V as VARIANT_TEST_KEY_EXPIRATION, d as storageStoreSetEnabledVariantTestKeys, t as translate, e as localizationStoreOnChange, h as currencyFormat } from './localization-dc19e8bb.js';
|
|
5
5
|
import { z as zonosStore, g as getZonosStoreTheme, m as mergeConfig } from './zonosStore-8e19daff.js';
|
|
6
6
|
import { b as buildCartItemsByTempCart } from './buildCartItemsByTempCart-a117f75d.js';
|
|
7
|
-
import { h as handleFetch,
|
|
7
|
+
import { h as handleFetch, g as getIsTestMode, j as jsonParse, l as logError, b as getAdditionalLogMetadata, s as sendErrorLog, a as getIsStagingMode, i as isCheckoutMobile } from './handleFetch-a844cac1.js';
|
|
8
8
|
import { u as updateCheckoutSessionAttributes } from './updateCheckoutSessionAttributes-40e301a4.js';
|
|
9
9
|
import { l as log, g as getElapsedTime, b as allLogs } from './VarianceTest-572cecf5.js';
|
|
10
10
|
import { _ as _getIsValidCartId, c as checkoutHiddenBtnSelector, a as checkoutHiddenInternationalBtnSelector, d as domesticRedirectedBtnSelector, g as getAbandonedCartRenewTokenValue } from './CheckoutConfig-724d7bae.js';
|
|
@@ -93,63 +93,6 @@ const buildCartUrl = ({ cartId, checkoutSessionId, customerAddress1, customerAdd
|
|
|
93
93
|
return `${hostedCheckoutUrl}?${urlParams.toString()}`;
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
-
/**
|
|
97
|
-
* Fetch the checkout/cart ID from the BigCommerce Storefront Cart API.
|
|
98
|
-
* The `/checkout` page URL does not include the checkout ID, so we
|
|
99
|
-
* retrieve it from `/api/storefront/cart` which returns the active cart(s).
|
|
100
|
-
*/
|
|
101
|
-
const fetchCheckoutId = async () => {
|
|
102
|
-
var _a, _b;
|
|
103
|
-
try {
|
|
104
|
-
const response = await fetch('/api/storefront/cart', {
|
|
105
|
-
credentials: 'same-origin',
|
|
106
|
-
headers: {
|
|
107
|
-
Accept: 'application/json',
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
if (!response.ok) {
|
|
111
|
-
log(`Failed to fetch BigCommerce cart: ${String(response.status)}`, 'error');
|
|
112
|
-
return null;
|
|
113
|
-
}
|
|
114
|
-
const carts = (await response.json());
|
|
115
|
-
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;
|
|
116
|
-
}
|
|
117
|
-
catch (error) {
|
|
118
|
-
logError('Error fetching BigCommerce cart data', error);
|
|
119
|
-
return null;
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
/**
|
|
123
|
-
* Fetch checkout data from the BigCommerce Storefront API.
|
|
124
|
-
* This API is cookie-authenticated (same-origin), so no token is needed.
|
|
125
|
-
*/
|
|
126
|
-
const fetchBigCommerceCheckout = async (checkoutId) => {
|
|
127
|
-
try {
|
|
128
|
-
const response = await fetch(`/api/storefront/checkouts/${checkoutId}?include=customer.customerGroup,customer.addresses`, {
|
|
129
|
-
credentials: 'same-origin',
|
|
130
|
-
headers: {
|
|
131
|
-
Accept: 'application/json',
|
|
132
|
-
'Content-Type': 'application/json',
|
|
133
|
-
},
|
|
134
|
-
});
|
|
135
|
-
if (!response.ok) {
|
|
136
|
-
log(`Failed to fetch BigCommerce checkout: ${String(response.status)}`, 'error');
|
|
137
|
-
return null;
|
|
138
|
-
}
|
|
139
|
-
return (await response.json());
|
|
140
|
-
}
|
|
141
|
-
catch (error) {
|
|
142
|
-
logError('Error fetching BigCommerce checkout data', error);
|
|
143
|
-
return null;
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* Whether the BigCommerce shopper is already logged in. We key off the
|
|
148
|
-
* customer's numeric `id` since the storefront API populates it only for
|
|
149
|
-
* authenticated sessions (guest checkouts have an empty `customer` object).
|
|
150
|
-
*/
|
|
151
|
-
const isBigCommerceCustomerLoggedIn = (checkout) => { var _a; return !!((_a = checkout === null || checkout === void 0 ? void 0 : checkout.customer) === null || _a === void 0 ? void 0 : _a.id); };
|
|
152
|
-
|
|
153
96
|
/**
|
|
154
97
|
* The query flag that BigCommerce carries back to `cart.php` after the
|
|
155
98
|
* shopper logs in. When present, Zonos-elements knows to resume the
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { r as registerInstance, e as getAssetPath, h, a as Host } from './index-cfd394c8.js';
|
|
2
|
-
import { d as cartStore } from './cart-
|
|
2
|
+
import { d as cartStore } from './cart-663ef7d5.js';
|
|
3
3
|
import { c as cleanHtmlMarkdown } from './cleanHtmlMarkdown-5f7856f2.js';
|
|
4
4
|
import { f as zonosStoreFontFamily } from './zonosStore-8e19daff.js';
|
|
5
5
|
import { c as classes } from './classes-0d95c529.js';
|
|
6
6
|
import { s as styles } from './styles-6fc2fad9.js';
|
|
7
|
-
import './localization-
|
|
7
|
+
import './localization-dc19e8bb.js';
|
|
8
8
|
import './handleFetch-a844cac1.js';
|
|
9
9
|
import './VarianceTest-572cecf5.js';
|
|
10
10
|
import './isDarkColor-566f04c5.js';
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { r as registerInstance, d as createEvent, h, F as Fragment, a as Host, g as getElement } from './index-cfd394c8.js';
|
|
2
|
-
import { b as stripeStore, c as stripeStoreRetrievePayment, t as trackConversionEvent, P as stripeStoreResetPromoCode, F as stripeStoreReset, Q as stripeStoreMessageBasedOnStatus, d as cartStore, u as cartStoreNextStep, G as cartStoreOnChange } from './cart-
|
|
3
|
-
import { s as submitAnalytics, c as paypalStoreReset, a as paypalStore, b as paypalInitScript } from './paypal-
|
|
4
|
-
import { t as translate, s as storageStore, l as localizationStore,
|
|
2
|
+
import { b as stripeStore, c as stripeStoreRetrievePayment, t as trackConversionEvent, P as stripeStoreResetPromoCode, F as stripeStoreReset, Q as stripeStoreMessageBasedOnStatus, d as cartStore, u as cartStoreNextStep, G as cartStoreOnChange } from './cart-663ef7d5.js';
|
|
3
|
+
import { s as submitAnalytics, c as paypalStoreReset, a as paypalStore, b as paypalInitScript } from './paypal-cdbe69ef.js';
|
|
4
|
+
import { t as translate, s as storageStore, l as localizationStore, v as translationStoreOnChange } from './localization-dc19e8bb.js';
|
|
5
5
|
import { z as zonosStore } from './zonosStore-8e19daff.js';
|
|
6
6
|
import { h as handleFetch, s as sendErrorLog, g as getIsTestMode, i as isCheckoutMobile, a as getIsStagingMode } from './handleFetch-a844cac1.js';
|
|
7
7
|
import { c as createCustomEvent } from './createCustomEvent-58159025.js';
|
|
8
8
|
import { g as getBorderRadius } from './getBorderRadius-d23f47a6.js';
|
|
9
9
|
import { l as log, b as allLogs } from './VarianceTest-572cecf5.js';
|
|
10
|
-
import { i as isCollectMobile, a as isCollectTablet, e as collectStore } from './isCollectMobileTablet-
|
|
10
|
+
import { i as isCollectMobile, a as isCollectTablet, e as collectStore } from './isCollectMobileTablet-24c912b1.js';
|
|
11
11
|
import { c as classes } from './classes-0d95c529.js';
|
|
12
12
|
import { l as languages } from './ILanguage-cd6acb72.js';
|
|
13
|
-
import { r as renderCheckoutCurrency } from './renderCheckoutCurrency-
|
|
14
|
-
import { p as placeTestOrder } from './placeTestOrder-
|
|
13
|
+
import { r as renderCheckoutCurrency } from './renderCheckoutCurrency-fb1cbd28.js';
|
|
14
|
+
import { p as placeTestOrder } from './placeTestOrder-ba67e208.js';
|
|
15
15
|
import { r as renderFallback } from './renderFallback-b250f4e9.js';
|
|
16
16
|
import './isDarkColor-566f04c5.js';
|
|
17
17
|
import './isContrastColor-fbddacb6.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { r as registerInstance, h, a as Host, F as Fragment } from './index-cfd394c8.js';
|
|
2
|
-
import { b as stripeStore, i as initStripeElements, c as stripeStoreRetrievePayment, d as cartStore, n as cartStoreUpdateToErrorState, e as cartStoreUpdateItems, j as stripeStoreInitCheckoutSession, k as stripeStoreGetPaymentIntent, w as stripeStoreUpdateCheckoutSessionBaseCurrency, C as stripeStoreConfirmPayment, H as stripeStoreOnChange, F as stripeStoreReset, f as cartStoreReset } from './cart-
|
|
3
|
-
import { i as isCollectMobile, a as isCollectTablet, c as collectStoreUpdateSelectedShippingOption, b as collectStoreInitShippingInfo, d as collectStoreAsyncAddressUpdate, e as collectStore } from './isCollectMobileTablet-
|
|
4
|
-
import { p as paypalStoreHasPaypalEnabled, a as paypalStore } from './paypal-
|
|
5
|
-
import { s as storageStore, t as translate,
|
|
2
|
+
import { b as stripeStore, i as initStripeElements, c as stripeStoreRetrievePayment, d as cartStore, n as cartStoreUpdateToErrorState, e as cartStoreUpdateItems, j as stripeStoreInitCheckoutSession, k as stripeStoreGetPaymentIntent, w as stripeStoreUpdateCheckoutSessionBaseCurrency, C as stripeStoreConfirmPayment, H as stripeStoreOnChange, F as stripeStoreReset, f as cartStoreReset } from './cart-663ef7d5.js';
|
|
3
|
+
import { i as isCollectMobile, a as isCollectTablet, c as collectStoreUpdateSelectedShippingOption, b as collectStoreInitShippingInfo, d as collectStoreAsyncAddressUpdate, e as collectStore } from './isCollectMobileTablet-24c912b1.js';
|
|
4
|
+
import { p as paypalStoreHasPaypalEnabled, a as paypalStore } from './paypal-cdbe69ef.js';
|
|
5
|
+
import { s as storageStore, t as translate, e as localizationStoreOnChange, h as currencyFormat, l as localizationStore } from './localization-dc19e8bb.js';
|
|
6
6
|
import { z as zonosStore } from './zonosStore-8e19daff.js';
|
|
7
7
|
import { b as buildCartItemsByTempCart } from './buildCartItemsByTempCart-a117f75d.js';
|
|
8
8
|
import { h as handleFetch, s as sendErrorLog, l as logError, g as getIsTestMode } from './handleFetch-a844cac1.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, d as createEvent, h, a as Host } from './index-cfd394c8.js';
|
|
2
|
-
import { b as stripeStore } from './cart-
|
|
3
|
-
import {
|
|
2
|
+
import { b as stripeStore } from './cart-663ef7d5.js';
|
|
3
|
+
import { j as getOverridenZCountry, k as isValidSelector, m as initLocalizationStore, s as storageStore, c as localizationStoreUpdateSelectedCountryCode } from './localization-dc19e8bb.js';
|
|
4
4
|
import { z as zonosStore, e as zonosStoreInitSetting, f as zonosStoreFontFamily } from './zonosStore-8e19daff.js';
|
|
5
5
|
import { g as getGenericSettingsOverride, i as iframeServices, a as injectPrivateIframe } from './getGenericSettingsOverride-0bc3e118.js';
|
|
6
6
|
import { h as handleFetch, l as logError } from './handleFetch-a844cac1.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, h, a as Host, g as getElement } from './index-cfd394c8.js';
|
|
2
|
-
import { l as localizationStore } from './localization-
|
|
2
|
+
import { l as localizationStore } from './localization-dc19e8bb.js';
|
|
3
3
|
import { f as zonosStoreFontFamily } from './zonosStore-8e19daff.js';
|
|
4
4
|
import { c as classes } from './classes-0d95c529.js';
|
|
5
5
|
import './handleFetch-a844cac1.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as registerInstance, h, a as Host, g as getElement } from './index-cfd394c8.js';
|
|
2
|
-
import {
|
|
2
|
+
import { c as localizationStoreUpdateSelectedCountryCode, t as translate, l as localizationStore } from './localization-dc19e8bb.js';
|
|
3
3
|
import { f as zonosStoreFontFamily } from './zonosStore-8e19daff.js';
|
|
4
4
|
import { f as formatStringWithLinks } from './formatStringWithLinks-9e819405.js';
|
|
5
5
|
import { i as isDarkColor } from './isDarkColor-566f04c5.js';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { r as registerInstance, d as createEvent, h, F as Fragment, a as Host } from './index-cfd394c8.js';
|
|
2
|
-
import { l as localizationStore, t as translate,
|
|
2
|
+
import { l as localizationStore, t as translate, h as currencyFormat } from './localization-dc19e8bb.js';
|
|
3
3
|
import { z as zonosStore } from './zonosStore-8e19daff.js';
|
|
4
4
|
import { c as classes } from './classes-0d95c529.js';
|
|
5
5
|
import { f as formatStringWithLinks } from './formatStringWithLinks-9e819405.js';
|
|
6
|
-
import { h as hasInclusivePrice, T as TAXES_KEY, D as DUTY_KEY } from './hasInclusivePrice-
|
|
6
|
+
import { h as hasInclusivePrice, T as TAXES_KEY, D as DUTY_KEY } from './hasInclusivePrice-f8bd057d.js';
|
|
7
7
|
import { g as getHasMoreSpaceOnRight } from './getHasMoreSpaceOnRight-70eb913a.js';
|
|
8
8
|
import { e as euCountryCodes } from './TaxId-50d72254.js';
|
|
9
9
|
import './handleFetch-a844cac1.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as registerInstance, h, a as Host, g as getElement } from './index-cfd394c8.js';
|
|
2
2
|
import { d as debounce_1 } from './debounce-58e4ff3e.js';
|
|
3
|
-
import { l as localizationStore,
|
|
3
|
+
import { l as localizationStore, k as isValidSelector, t as translate, g as getZCountryUrlParam, n as setZCountryUrlParam, o as currencyDisplay, p as currencyConvertAndFormat, q as currencyConvert, h as currencyFormat, r as shouldShowHelloWidget } from './localization-dc19e8bb.js';
|
|
4
4
|
import { z as zonosStore, g as getZonosStoreTheme, m as mergeConfig } from './zonosStore-8e19daff.js';
|
|
5
5
|
import { c as classes } from './classes-0d95c529.js';
|
|
6
6
|
import { h as handleFetch, l as logError } from './handleFetch-a844cac1.js';
|
|
@@ -329,49 +329,6 @@ const ZonosHello = class {
|
|
|
329
329
|
return hasMoreSpaceOnRight;
|
|
330
330
|
}
|
|
331
331
|
};
|
|
332
|
-
this.shouldRenderHello = (showLog = true) => {
|
|
333
|
-
var _a, _b;
|
|
334
|
-
if (!localizationStore.localizationLoaded) {
|
|
335
|
-
return false;
|
|
336
|
-
}
|
|
337
|
-
const { countryDisplayRules, showForCountries } = zonosStore.helloSettings;
|
|
338
|
-
const visibilityRules = countryDisplayRules === null || countryDisplayRules === void 0 ? void 0 : countryDisplayRules.widgetVisibility;
|
|
339
|
-
const selectedCountry = localizationStore.selectedCountryCode;
|
|
340
|
-
// Resolve behavior: deprecated showForCountries overrides widgetVisibility.behavior
|
|
341
|
-
// If showForCountries is an array of country codes, treat as legacy explicit list
|
|
342
|
-
const behavior = Array.isArray(showForCountries)
|
|
343
|
-
? showForCountries
|
|
344
|
-
: (showForCountries !== null && showForCountries !== void 0 ? showForCountries : visibilityRules === null || visibilityRules === void 0 ? void 0 : visibilityRules.behavior);
|
|
345
|
-
if (showLog && !localizationStore.isShippableCountry) {
|
|
346
|
-
log(`Hello: not shippable country - Show for countries: ${behavior}`);
|
|
347
|
-
}
|
|
348
|
-
// Legacy: explicit list of country codes from deprecated showForCountries
|
|
349
|
-
if (Array.isArray(behavior)) {
|
|
350
|
-
return !!selectedCountry && behavior.includes(selectedCountry);
|
|
351
|
-
}
|
|
352
|
-
// Determine base visibility from behavior
|
|
353
|
-
let isVisible;
|
|
354
|
-
if (behavior === 'ALL') {
|
|
355
|
-
isVisible = true;
|
|
356
|
-
}
|
|
357
|
-
else {
|
|
358
|
-
// Default: ONLY_SHIPPABLE
|
|
359
|
-
isVisible = localizationStore.isShippableCountry;
|
|
360
|
-
}
|
|
361
|
-
// Apply includedCountries — force show the widget for these countries
|
|
362
|
-
if (!isVisible &&
|
|
363
|
-
selectedCountry &&
|
|
364
|
-
((_a = visibilityRules === null || visibilityRules === void 0 ? void 0 : visibilityRules.includedCountries) === null || _a === void 0 ? void 0 : _a.includes(selectedCountry))) {
|
|
365
|
-
isVisible = true;
|
|
366
|
-
}
|
|
367
|
-
// Apply excludedCountries — force hide the widget for these countries
|
|
368
|
-
if (isVisible &&
|
|
369
|
-
selectedCountry &&
|
|
370
|
-
((_b = visibilityRules === null || visibilityRules === void 0 ? void 0 : visibilityRules.excludedCountries) === null || _b === void 0 ? void 0 : _b.includes(selectedCountry))) {
|
|
371
|
-
isVisible = false;
|
|
372
|
-
}
|
|
373
|
-
return isVisible;
|
|
374
|
-
};
|
|
375
332
|
}
|
|
376
333
|
showDialogHandler(showDialog) {
|
|
377
334
|
var _a;
|
|
@@ -547,7 +504,7 @@ const ZonosHello = class {
|
|
|
547
504
|
// The organization name can be changed after init with the updateOrganizationName method.
|
|
548
505
|
// This will cause the element to rerender with the new org name when it changes. (used for preview on dashboard)
|
|
549
506
|
this.peekMessage = this.getHelloPeekMessage(zonosStore.organizationName);
|
|
550
|
-
const showHello =
|
|
507
|
+
const showHello = shouldShowHelloWidget() && !!selectedCountryCode;
|
|
551
508
|
// If the condition for rendering Hello is met, set the toggle to true to trigger callback, should only trigger once
|
|
552
509
|
if (showHello && !this.isHelloWidgetRendered) {
|
|
553
510
|
this.handleHelloWidgetInitializedState({
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { r as registerInstance, h, a as Host } from './index-cfd394c8.js';
|
|
2
|
-
import { d as cartStore } from './cart-
|
|
3
|
-
import { t as translate } from './localization-
|
|
4
|
-
import { r as renderCheckoutCurrency } from './renderCheckoutCurrency-
|
|
2
|
+
import { d as cartStore } from './cart-663ef7d5.js';
|
|
3
|
+
import { t as translate } from './localization-dc19e8bb.js';
|
|
4
|
+
import { r as renderCheckoutCurrency } from './renderCheckoutCurrency-fb1cbd28.js';
|
|
5
5
|
import { c as classes } from './classes-0d95c529.js';
|
|
6
|
-
import { c as invoiceStore } from './invoice-
|
|
6
|
+
import { c as invoiceStore } from './invoice-db7211a6.js';
|
|
7
7
|
import { r as renderFallback } from './renderFallback-b250f4e9.js';
|
|
8
8
|
import './zonosStore-8e19daff.js';
|
|
9
9
|
import './VarianceTest-572cecf5.js';
|