@zonos/elements 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/zonos-checkout.cjs.entry.js +77 -0
- package/dist/collection/components/utils/checkout/isBigCommerceCheckoutBypassEnabled.js +74 -0
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +8 -0
- package/dist/esm/index.js +7 -7
- package/dist/esm/zonos-checkout.entry.js +77 -0
- package/dist/esm-es5/index.js +4 -4
- package/dist/esm-es5/zonos-checkout.entry.js +38 -13
- package/dist/scripts/index.d.ts +14 -0
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/utils/checkout/isBigCommerceCheckoutBypassEnabled.d.ts +11 -0
- package/dist/types/types/checkout/CheckoutConfig.d.ts +14 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-0457f579.entry.js +1 -0
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
- package/dist/zonos-elements/{p-DPZSD7Kg.system.js → p-DCS8qcL6.system.js} +4 -4
- package/dist/zonos-elements/{p-5236c676.system.entry.js → p-be1237fc.system.entry.js} +68 -43
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-f8b50aa0.entry.js +0 -1
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -131,7 +131,7 @@ const getZonosQaUrl = () => {
|
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
133
133
|
const qaUrl = extractZonosQaUrl(window.location.href);
|
|
134
|
-
const cdnUrl = "https://v1.4.
|
|
134
|
+
const cdnUrl = "https://v1.4.2.js.zonos.com";
|
|
135
135
|
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
136
136
|
if (!qaUrl &&
|
|
137
137
|
(cdnUrl.includes('test.') ||
|
|
@@ -420,10 +420,10 @@ const zonosLoadUrl = (() => {
|
|
|
420
420
|
return null;
|
|
421
421
|
})();
|
|
422
422
|
const startLoadTime = Date.now();
|
|
423
|
-
const ZONOS_URL = "https://v1.4.
|
|
424
|
-
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.
|
|
425
|
-
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.4.
|
|
426
|
-
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.
|
|
423
|
+
const ZONOS_URL = "https://v1.4.2.js.zonos.com";
|
|
424
|
+
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.2";
|
|
425
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.4.2";
|
|
426
|
+
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.2";
|
|
427
427
|
const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
|
|
428
428
|
const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
|
|
429
429
|
class Zonos {
|
|
@@ -441,7 +441,7 @@ Zonos.iframeLogType = typeof window !== 'undefined'
|
|
|
441
441
|
? new URLSearchParams(window.location.search).get('iframeLogType')
|
|
442
442
|
: null;
|
|
443
443
|
Zonos.isBigCommerce = false;
|
|
444
|
-
Zonos.releaseDate = "
|
|
444
|
+
Zonos.releaseDate = "1792599810755";
|
|
445
445
|
Zonos.isLegacyCheckout = false;
|
|
446
446
|
Zonos.googleAnalyticId = null;
|
|
447
447
|
Zonos.googleAnalyticReady = false;
|
|
@@ -466,7 +466,7 @@ Zonos.isNpm = true;
|
|
|
466
466
|
Zonos.zonosQaUrl = null;
|
|
467
467
|
Zonos.zonosQaUrlApi = null;
|
|
468
468
|
Zonos.trackEventLogs = [];
|
|
469
|
-
Zonos.version = `v${"1.4.
|
|
469
|
+
Zonos.version = `v${"1.4.2"}`;
|
|
470
470
|
Zonos.modeAlerted = false;
|
|
471
471
|
Zonos.cartData = null;
|
|
472
472
|
Zonos.paypal = null;
|
|
@@ -700,6 +700,76 @@ providedCountryCode) => {
|
|
|
700
700
|
return true;
|
|
701
701
|
};
|
|
702
702
|
|
|
703
|
+
const ZBYPASS_ON_VALUES = ['1', 'true', 'yes'];
|
|
704
|
+
/**
|
|
705
|
+
* Page-load result of reading the checkout `zBypass` query. Later calls on the
|
|
706
|
+
* same checkout URL reuse this so stripping the parameter does not change the
|
|
707
|
+
* answer.
|
|
708
|
+
*/
|
|
709
|
+
let consumedZBypassQuery = null;
|
|
710
|
+
const isCheckoutPage = () => {
|
|
711
|
+
return window.location.pathname.includes('/checkout');
|
|
712
|
+
};
|
|
713
|
+
const isAcceptedZBypassQuery = (rawValue) => {
|
|
714
|
+
if (rawValue === null) {
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
return ZBYPASS_ON_VALUES.includes(rawValue.trim().toLowerCase());
|
|
718
|
+
};
|
|
719
|
+
/**
|
|
720
|
+
* True only when zonos-settings set
|
|
721
|
+
* `checkoutSettings.plugins.bigcommerce.allowBypassQuery` to `true`.
|
|
722
|
+
*/
|
|
723
|
+
const isBypassQueryAllowed = () => {
|
|
724
|
+
var _a, _b;
|
|
725
|
+
return (((_b = (_a = zonosStore.zonosStore.checkoutSettings.plugins) === null || _a === void 0 ? void 0 : _a.bigcommerce) === null || _b === void 0 ? void 0 : _b.allowBypassQuery) === true);
|
|
726
|
+
};
|
|
727
|
+
/**
|
|
728
|
+
* Read an accepted `zBypass` query on the checkout page once, then remove it
|
|
729
|
+
* from the URL. A later call on that same URL returns the same answer.
|
|
730
|
+
*/
|
|
731
|
+
const readCheckoutZBypassQuery = () => {
|
|
732
|
+
const { pathname, search } = window.location;
|
|
733
|
+
if (consumedZBypassQuery &&
|
|
734
|
+
consumedZBypassQuery.pathname === pathname &&
|
|
735
|
+
consumedZBypassQuery.search === search) {
|
|
736
|
+
return consumedZBypassQuery.enabled;
|
|
737
|
+
}
|
|
738
|
+
const params = new URLSearchParams(search);
|
|
739
|
+
const accepted = isAcceptedZBypassQuery(params.get('zBypass'));
|
|
740
|
+
if (!accepted) {
|
|
741
|
+
consumedZBypassQuery = { enabled: false, pathname, search };
|
|
742
|
+
return false;
|
|
743
|
+
}
|
|
744
|
+
params.delete('zBypass');
|
|
745
|
+
const nextSearch = params.toString();
|
|
746
|
+
const hash = window.location.hash || '';
|
|
747
|
+
const nextUrl = `${pathname}${nextSearch ? `?${nextSearch}` : ''}${hash}`;
|
|
748
|
+
window.history.replaceState(window.history.state, document.title, nextUrl);
|
|
749
|
+
const enabled = isBypassQueryAllowed();
|
|
750
|
+
consumedZBypassQuery = {
|
|
751
|
+
enabled,
|
|
752
|
+
pathname,
|
|
753
|
+
search: window.location.search,
|
|
754
|
+
};
|
|
755
|
+
return enabled;
|
|
756
|
+
};
|
|
757
|
+
/**
|
|
758
|
+
* True when this BigCommerce checkout page should skip address detection.
|
|
759
|
+
* That is only when zonos-settings allows the `zBypass` query and this
|
|
760
|
+
* checkout URL has an accepted value. Storefront pages are never bypassed, so
|
|
761
|
+
* the query stays in the URL until checkout. The query is removed once, and
|
|
762
|
+
* later calls on that checkout URL keep the same answer. Nothing is written
|
|
763
|
+
* to storage.
|
|
764
|
+
*/
|
|
765
|
+
const isBigCommerceCheckoutBypassEnabled = () => {
|
|
766
|
+
var _a;
|
|
767
|
+
if (!((_a = window.Zonos) === null || _a === void 0 ? void 0 : _a.isBigCommerce) || !isCheckoutPage()) {
|
|
768
|
+
return false;
|
|
769
|
+
}
|
|
770
|
+
return readCheckoutZBypassQuery();
|
|
771
|
+
};
|
|
772
|
+
|
|
703
773
|
const FALLBACK_SHIP_TO_COUNTRY_SELECTOR = 'select[name="shippingAddress.countryCode"]';
|
|
704
774
|
/**
|
|
705
775
|
* Native BigCommerce shipping-step "Continue" button. Clicking it commits the
|
|
@@ -800,6 +870,13 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
|
|
|
800
870
|
if (!window.Zonos.isBigCommerce) {
|
|
801
871
|
return;
|
|
802
872
|
}
|
|
873
|
+
// Only the native checkout page skips address detection. Storefront pages
|
|
874
|
+
// still run the domestic-session handoff below, and they do not consume
|
|
875
|
+
// a `zBypass` query, so the parameter can survive until `/checkout`.
|
|
876
|
+
if (window.location.pathname.includes('/checkout') &&
|
|
877
|
+
isBigCommerceCheckoutBypassEnabled()) {
|
|
878
|
+
return;
|
|
879
|
+
}
|
|
803
880
|
/**
|
|
804
881
|
* Keep checking.
|
|
805
882
|
* @returns `true` if the caller should stop polling — either because the user
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { zonosStore } from "../../store/zonosStore";
|
|
2
|
+
const ZBYPASS_ON_VALUES = ['1', 'true', 'yes'];
|
|
3
|
+
/**
|
|
4
|
+
* Page-load result of reading the checkout `zBypass` query. Later calls on the
|
|
5
|
+
* same checkout URL reuse this so stripping the parameter does not change the
|
|
6
|
+
* answer.
|
|
7
|
+
*/
|
|
8
|
+
let consumedZBypassQuery = null;
|
|
9
|
+
const isCheckoutPage = () => {
|
|
10
|
+
return window.location.pathname.includes('/checkout');
|
|
11
|
+
};
|
|
12
|
+
const isAcceptedZBypassQuery = (rawValue) => {
|
|
13
|
+
if (rawValue === null) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return ZBYPASS_ON_VALUES.includes(rawValue.trim().toLowerCase());
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* True only when zonos-settings set
|
|
20
|
+
* `checkoutSettings.plugins.bigcommerce.allowBypassQuery` to `true`.
|
|
21
|
+
*/
|
|
22
|
+
const isBypassQueryAllowed = () => {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
return (((_b = (_a = zonosStore.checkoutSettings.plugins) === null || _a === void 0 ? void 0 : _a.bigcommerce) === null || _b === void 0 ? void 0 : _b.allowBypassQuery) === true);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Read an accepted `zBypass` query on the checkout page once, then remove it
|
|
28
|
+
* from the URL. A later call on that same URL returns the same answer.
|
|
29
|
+
*/
|
|
30
|
+
const readCheckoutZBypassQuery = () => {
|
|
31
|
+
const { pathname, search } = window.location;
|
|
32
|
+
if (consumedZBypassQuery &&
|
|
33
|
+
consumedZBypassQuery.pathname === pathname &&
|
|
34
|
+
consumedZBypassQuery.search === search) {
|
|
35
|
+
return consumedZBypassQuery.enabled;
|
|
36
|
+
}
|
|
37
|
+
const params = new URLSearchParams(search);
|
|
38
|
+
const accepted = isAcceptedZBypassQuery(params.get('zBypass'));
|
|
39
|
+
if (!accepted) {
|
|
40
|
+
consumedZBypassQuery = { enabled: false, pathname, search };
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
params.delete('zBypass');
|
|
44
|
+
const nextSearch = params.toString();
|
|
45
|
+
const hash = window.location.hash || '';
|
|
46
|
+
const nextUrl = `${pathname}${nextSearch ? `?${nextSearch}` : ''}${hash}`;
|
|
47
|
+
window.history.replaceState(window.history.state, document.title, nextUrl);
|
|
48
|
+
const enabled = isBypassQueryAllowed();
|
|
49
|
+
consumedZBypassQuery = {
|
|
50
|
+
enabled,
|
|
51
|
+
pathname,
|
|
52
|
+
search: window.location.search,
|
|
53
|
+
};
|
|
54
|
+
return enabled;
|
|
55
|
+
};
|
|
56
|
+
/** Clears the page-load query result. Tests use this between cases. */
|
|
57
|
+
export const resetBigCommerceCheckoutBypassCache = () => {
|
|
58
|
+
consumedZBypassQuery = null;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* True when this BigCommerce checkout page should skip address detection.
|
|
62
|
+
* That is only when zonos-settings allows the `zBypass` query and this
|
|
63
|
+
* checkout URL has an accepted value. Storefront pages are never bypassed, so
|
|
64
|
+
* the query stays in the URL until checkout. The query is removed once, and
|
|
65
|
+
* later calls on that checkout URL keep the same answer. Nothing is written
|
|
66
|
+
* to storage.
|
|
67
|
+
*/
|
|
68
|
+
export const isBigCommerceCheckoutBypassEnabled = () => {
|
|
69
|
+
var _a;
|
|
70
|
+
if (!((_a = window.Zonos) === null || _a === void 0 ? void 0 : _a.isBigCommerce) || !isCheckoutPage()) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return readCheckoutZBypassQuery();
|
|
74
|
+
};
|
|
@@ -5,6 +5,7 @@ import { fetchBigCommerceCheckout, fetchCheckoutId, } from "./bigcommerceStorefr
|
|
|
5
5
|
import { buildBigcommerceRedirectUrl } from "./buildBigcommerceRedirectUrl";
|
|
6
6
|
import { checkBigCommerceBypassCustomerGroup } from "./checkBigCommerceBypassCustomerGroup";
|
|
7
7
|
import { checkBigCommerceForceLogin } from "./checkBigCommerceForceLogin";
|
|
8
|
+
import { isBigCommerceCheckoutBypassEnabled } from "./isBigCommerceCheckoutBypassEnabled";
|
|
8
9
|
import { isShippableCountry } from "./isShippableCountry";
|
|
9
10
|
import { log } from "../logging/log";
|
|
10
11
|
import { logError } from "../logging/logError";
|
|
@@ -108,6 +109,13 @@ export const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedi
|
|
|
108
109
|
if (!window.Zonos.isBigCommerce) {
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
112
|
+
// Only the native checkout page skips address detection. Storefront pages
|
|
113
|
+
// still run the domestic-session handoff below, and they do not consume
|
|
114
|
+
// a `zBypass` query, so the parameter can survive until `/checkout`.
|
|
115
|
+
if (window.location.pathname.includes('/checkout') &&
|
|
116
|
+
isBigCommerceCheckoutBypassEnabled()) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
111
119
|
/**
|
|
112
120
|
* Keep checking.
|
|
113
121
|
* @returns `true` if the caller should stop polling — either because the user
|
package/dist/esm/index.js
CHANGED
|
@@ -131,7 +131,7 @@ const getZonosQaUrl = () => {
|
|
|
131
131
|
return null;
|
|
132
132
|
}
|
|
133
133
|
const qaUrl = extractZonosQaUrl(window.location.href);
|
|
134
|
-
const cdnUrl = "https://v1.4.
|
|
134
|
+
const cdnUrl = "https://v1.4.2.js.zonos.com";
|
|
135
135
|
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
136
136
|
if (!qaUrl &&
|
|
137
137
|
(cdnUrl.includes('test.') ||
|
|
@@ -420,10 +420,10 @@ const zonosLoadUrl = (() => {
|
|
|
420
420
|
return null;
|
|
421
421
|
})();
|
|
422
422
|
const startLoadTime = Date.now();
|
|
423
|
-
const ZONOS_URL = "https://v1.4.
|
|
424
|
-
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.
|
|
425
|
-
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.4.
|
|
426
|
-
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.
|
|
423
|
+
const ZONOS_URL = "https://v1.4.2.js.zonos.com";
|
|
424
|
+
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || "https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.2";
|
|
425
|
+
const UNPKG_ZONOS_URL = "https://unpkg.com/@zonos/elements@1.4.2";
|
|
426
|
+
const CDNJS_ZONOS_URL = "https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.2";
|
|
427
427
|
const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
|
|
428
428
|
const GOOGLE_FONT_REGEX = /^https:\/\/fonts\.googleapis\.com/;
|
|
429
429
|
class Zonos {
|
|
@@ -441,7 +441,7 @@ Zonos.iframeLogType = typeof window !== 'undefined'
|
|
|
441
441
|
? new URLSearchParams(window.location.search).get('iframeLogType')
|
|
442
442
|
: null;
|
|
443
443
|
Zonos.isBigCommerce = false;
|
|
444
|
-
Zonos.releaseDate = "
|
|
444
|
+
Zonos.releaseDate = "1792599810755";
|
|
445
445
|
Zonos.isLegacyCheckout = false;
|
|
446
446
|
Zonos.googleAnalyticId = null;
|
|
447
447
|
Zonos.googleAnalyticReady = false;
|
|
@@ -466,7 +466,7 @@ Zonos.isNpm = true;
|
|
|
466
466
|
Zonos.zonosQaUrl = null;
|
|
467
467
|
Zonos.zonosQaUrlApi = null;
|
|
468
468
|
Zonos.trackEventLogs = [];
|
|
469
|
-
Zonos.version = `v${"1.4.
|
|
469
|
+
Zonos.version = `v${"1.4.2"}`;
|
|
470
470
|
Zonos.modeAlerted = false;
|
|
471
471
|
Zonos.cartData = null;
|
|
472
472
|
Zonos.paypal = null;
|
|
@@ -698,6 +698,76 @@ providedCountryCode) => {
|
|
|
698
698
|
return true;
|
|
699
699
|
};
|
|
700
700
|
|
|
701
|
+
const ZBYPASS_ON_VALUES = ['1', 'true', 'yes'];
|
|
702
|
+
/**
|
|
703
|
+
* Page-load result of reading the checkout `zBypass` query. Later calls on the
|
|
704
|
+
* same checkout URL reuse this so stripping the parameter does not change the
|
|
705
|
+
* answer.
|
|
706
|
+
*/
|
|
707
|
+
let consumedZBypassQuery = null;
|
|
708
|
+
const isCheckoutPage = () => {
|
|
709
|
+
return window.location.pathname.includes('/checkout');
|
|
710
|
+
};
|
|
711
|
+
const isAcceptedZBypassQuery = (rawValue) => {
|
|
712
|
+
if (rawValue === null) {
|
|
713
|
+
return false;
|
|
714
|
+
}
|
|
715
|
+
return ZBYPASS_ON_VALUES.includes(rawValue.trim().toLowerCase());
|
|
716
|
+
};
|
|
717
|
+
/**
|
|
718
|
+
* True only when zonos-settings set
|
|
719
|
+
* `checkoutSettings.plugins.bigcommerce.allowBypassQuery` to `true`.
|
|
720
|
+
*/
|
|
721
|
+
const isBypassQueryAllowed = () => {
|
|
722
|
+
var _a, _b;
|
|
723
|
+
return (((_b = (_a = zonosStore.checkoutSettings.plugins) === null || _a === void 0 ? void 0 : _a.bigcommerce) === null || _b === void 0 ? void 0 : _b.allowBypassQuery) === true);
|
|
724
|
+
};
|
|
725
|
+
/**
|
|
726
|
+
* Read an accepted `zBypass` query on the checkout page once, then remove it
|
|
727
|
+
* from the URL. A later call on that same URL returns the same answer.
|
|
728
|
+
*/
|
|
729
|
+
const readCheckoutZBypassQuery = () => {
|
|
730
|
+
const { pathname, search } = window.location;
|
|
731
|
+
if (consumedZBypassQuery &&
|
|
732
|
+
consumedZBypassQuery.pathname === pathname &&
|
|
733
|
+
consumedZBypassQuery.search === search) {
|
|
734
|
+
return consumedZBypassQuery.enabled;
|
|
735
|
+
}
|
|
736
|
+
const params = new URLSearchParams(search);
|
|
737
|
+
const accepted = isAcceptedZBypassQuery(params.get('zBypass'));
|
|
738
|
+
if (!accepted) {
|
|
739
|
+
consumedZBypassQuery = { enabled: false, pathname, search };
|
|
740
|
+
return false;
|
|
741
|
+
}
|
|
742
|
+
params.delete('zBypass');
|
|
743
|
+
const nextSearch = params.toString();
|
|
744
|
+
const hash = window.location.hash || '';
|
|
745
|
+
const nextUrl = `${pathname}${nextSearch ? `?${nextSearch}` : ''}${hash}`;
|
|
746
|
+
window.history.replaceState(window.history.state, document.title, nextUrl);
|
|
747
|
+
const enabled = isBypassQueryAllowed();
|
|
748
|
+
consumedZBypassQuery = {
|
|
749
|
+
enabled,
|
|
750
|
+
pathname,
|
|
751
|
+
search: window.location.search,
|
|
752
|
+
};
|
|
753
|
+
return enabled;
|
|
754
|
+
};
|
|
755
|
+
/**
|
|
756
|
+
* True when this BigCommerce checkout page should skip address detection.
|
|
757
|
+
* That is only when zonos-settings allows the `zBypass` query and this
|
|
758
|
+
* checkout URL has an accepted value. Storefront pages are never bypassed, so
|
|
759
|
+
* the query stays in the URL until checkout. The query is removed once, and
|
|
760
|
+
* later calls on that checkout URL keep the same answer. Nothing is written
|
|
761
|
+
* to storage.
|
|
762
|
+
*/
|
|
763
|
+
const isBigCommerceCheckoutBypassEnabled = () => {
|
|
764
|
+
var _a;
|
|
765
|
+
if (!((_a = window.Zonos) === null || _a === void 0 ? void 0 : _a.isBigCommerce) || !isCheckoutPage()) {
|
|
766
|
+
return false;
|
|
767
|
+
}
|
|
768
|
+
return readCheckoutZBypassQuery();
|
|
769
|
+
};
|
|
770
|
+
|
|
701
771
|
const FALLBACK_SHIP_TO_COUNTRY_SELECTOR = 'select[name="shippingAddress.countryCode"]';
|
|
702
772
|
/**
|
|
703
773
|
* Native BigCommerce shipping-step "Continue" button. Clicking it commits the
|
|
@@ -798,6 +868,13 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
|
|
|
798
868
|
if (!window.Zonos.isBigCommerce) {
|
|
799
869
|
return;
|
|
800
870
|
}
|
|
871
|
+
// Only the native checkout page skips address detection. Storefront pages
|
|
872
|
+
// still run the domestic-session handoff below, and they do not consume
|
|
873
|
+
// a `zBypass` query, so the parameter can survive until `/checkout`.
|
|
874
|
+
if (window.location.pathname.includes('/checkout') &&
|
|
875
|
+
isBigCommerceCheckoutBypassEnabled()) {
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
801
878
|
/**
|
|
802
879
|
* Keep checking.
|
|
803
880
|
* @returns `true` if the caller should stop polling — either because the user
|
package/dist/esm-es5/index.js
CHANGED
|
@@ -54,7 +54,7 @@ var n=new URL(e).searchParams;var o=n.get("zonosQaUrl");if(!o){return null}var t
|
|
|
54
54
|
* When developing, if the script load is from `dev.elements.zonos.com`,
|
|
55
55
|
* it would load script from that same domain instead of loading from cdn
|
|
56
56
|
*/
|
|
57
|
-
var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.4.
|
|
57
|
+
var e=window&&window.location.href.includes("forceLoadCdn");if(typeof window==="undefined"||e){return null}var n=extractZonosQaUrl(window.location.href);var o="https://v1.4.2.js.zonos.com";
|
|
58
58
|
// when the qaUrl is not set and the built URL is from the test domain, use the test domain for testing
|
|
59
59
|
if(!n&&(o.includes("test.")||
|
|
60
60
|
// Vercel git domain
|
|
@@ -99,15 +99,15 @@ return[4/*yield*/,new Promise((function(e){return setTimeout(e,500)}))];case 2:
|
|
|
99
99
|
e.sent();return[2/*return*/,getCartInfoById({cartId:l,retries:d-1})];case 3:if(c){return[2/*return*/,null]}return[2/*return*/,Object.assign(Object.assign({},s),{zonosMode:u})]}}))}))};var setupCartDataWithSettings=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r;return __generator(this,(function(i){switch(i.label){case 0:n=_getIsValidCartId(e),o=n.isDgsCartId,t=n.isLegacyCartId;if(!t&&!o){logError("[ZONOS - loadZonos] invalid cart id");return[2/*return*/,null]}return[4/*yield*/,getCartInfoById({cartId:e,retries:5})];case 1:r=i.sent();log("[ZONOS - loadZonos] getting temp cart data","info",r);if(!r){logError("[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.");return[2/*return*/,null]}window.Zonos.storeId=r.cartData.storeId;window.Zonos.zonosApiKey=r.cartData.credentialToken;window.Zonos.zonosMode=r.zonosMode;return[2/*return*/,{cartData:r.cartData,settings:r.settings,storeFavicon:r.storeFaviconUrl,storeId:r.cartData.storeId,storeLogo:r.storeLogoUrl,zonosApiKey:r.cartData.credentialToken}]}}))}))};var _a;
|
|
100
100
|
/**
|
|
101
101
|
* Get the load version and url based on the loadScriptSrc, if the domain that used to load `zonos.js` is in white listed domains, use currentLoadScriptUrl as the load url instead, if zonosQaUrl exists, it would also fall under the white listed domain
|
|
102
|
-
*/var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var startLoadTime=Date.now();var ZONOS_URL="https://v1.4.
|
|
102
|
+
*/var zonosLoadUrl=function(){if(typeof document==="undefined"){return null}var e=document.querySelector('script[src*="/zonos.js"]');var n=checkIfLoadVersionDomain({loadScriptSrc:e===null||e===void 0?void 0:e.src}),o=n.currentLoadScriptUrl,t=n.isWhiteListed;if(t){return o}return null}();var startLoadTime=Date.now();var ZONOS_URL="https://v1.4.2.js.zonos.com";var JS_DELIVR_ZONOS_URL=zonosLoadUrl||"https://cdn.jsdelivr.net/npm/@zonos/elements@1.4.2";var UNPKG_ZONOS_URL="https://unpkg.com/@zonos/elements@1.4.2";var CDNJS_ZONOS_URL="https://cdnjs.cloudflare.com/ajax/libs/zonos-elements/1.4.2";var GOOGLE_FONT_URL="https://fonts.googleapis.com";var GOOGLE_FONT_REGEX=/^https:\/\/fonts\.googleapis\.com/;var Zonos=/** @class */function(){function e(){}return e}();_a=Zonos;Zonos.doneInit=false;Zonos.cartSettings=null;
|
|
103
103
|
// if query 'zonosDebug=1' param from url, debug mode is on
|
|
104
|
-
Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="
|
|
104
|
+
Zonos.debug=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosDebug=1/);Zonos.zonosConversionTest=typeof window!=="undefined"&&!!window.location.search.match(/\?.*(&*)zonosConversionTest/);Zonos._paypalMockResponse=null;Zonos.iframeLogType=typeof window!=="undefined"?new URLSearchParams(window.location.search).get("iframeLogType"):null;Zonos.isBigCommerce=false;Zonos.releaseDate="1792599810755";Zonos.isLegacyCheckout=false;Zonos.googleAnalyticId=null;Zonos.googleAnalyticReady=false;Zonos.facebookPixelId=null;Zonos.facebookPixelReady=false;Zonos.startLoadTime=startLoadTime;Zonos.domain=typeof window!=="undefined"?// domain that embeds the iframe
|
|
105
105
|
window.location!=window.parent.location&&document.referrer||
|
|
106
106
|
// current domain
|
|
107
107
|
document.location.hostname:"";Zonos.showBaseForeign=typeof window!=="undefined"&&window.location.search.includes("zonosShowBaseForeign");Zonos.overrideUseCustomAddressForm=false;Zonos.isCollect=false;Zonos.isInvoice=false;
|
|
108
108
|
/**
|
|
109
109
|
* By default, the package will load from npm
|
|
110
|
-
*/Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.4.
|
|
110
|
+
*/Zonos.isNpm=true;Zonos.zonosQaUrl=null;Zonos.zonosQaUrlApi=null;Zonos.trackEventLogs=[];Zonos.version="v".concat("1.4.2");Zonos.modeAlerted=false;Zonos.cartData=null;Zonos.paypal=null;Zonos.zonosMode=null;Zonos.IframeService=IframeService;Zonos.getCurrentTimestamp=function(){return(new Date).getTime()};Zonos.zonosController=null;Zonos.loadTimeApiInfoList=[];Zonos.logIntervalId=null;Zonos.init=function(e){return __awaiter(void 0,void 0,void 0,(function(){var n,o,t,r,i,a,s,u,c,l,d,f,v,m,_;return __generator(this,(function(p){switch(p.label){case 0:n=e.appearance,o=e.checkoutSettings,t=e.currencyConverter,r=e.helloSettings,i=e.onCountryChange,a=e.overrideCurrencyFormat,s=e.storeId,u=e.zonosApiKey;_a.cartId=getCartIdFromQueryParam();
|
|
111
111
|
// Expose the checkout cart callbacks on the global so Stripe loading can be
|
|
112
112
|
// gated on whether at least one of them is configured.
|
|
113
113
|
_a.createCartId=o===null||o===void 0?void 0:o.createCartId;
|
|
@@ -239,7 +239,28 @@ return h.map((function(e,t){return{index:t,option:e}})).sort((function(e,t){var
|
|
|
239
239
|
*/
|
|
240
240
|
t){if(e===void 0){e=true}if(!localizationStore.localizationLoaded){return false}if(t){var o=isCountryInShippingZone(t);if(e&&!o){log("Checkout: ".concat(t," is not a shippable country: ").concat(o))}return o}
|
|
241
241
|
// if localization is loaded and the localization is not a shippable country, keep the original click event
|
|
242
|
-
if(!localizationStore.isShippableCountry){if(e){log("Checkout: not shippable country")}return false}return true};var
|
|
242
|
+
if(!localizationStore.isShippableCountry){if(e){log("Checkout: not shippable country")}return false}return true};var ZBYPASS_ON_VALUES=["1","true","yes"];
|
|
243
|
+
/**
|
|
244
|
+
* Page-load result of reading the checkout `zBypass` query. Later calls on the
|
|
245
|
+
* same checkout URL reuse this so stripping the parameter does not change the
|
|
246
|
+
* answer.
|
|
247
|
+
*/var consumedZBypassQuery=null;var isCheckoutPage=function(){return window.location.pathname.includes("/checkout")};var isAcceptedZBypassQuery=function(e){if(e===null){return false}return ZBYPASS_ON_VALUES.includes(e.trim().toLowerCase())};
|
|
248
|
+
/**
|
|
249
|
+
* True only when zonos-settings set
|
|
250
|
+
* `checkoutSettings.plugins.bigcommerce.allowBypassQuery` to `true`.
|
|
251
|
+
*/var isBypassQueryAllowed=function(){var e,t;return((t=(e=zonosStore.checkoutSettings.plugins)===null||e===void 0?void 0:e.bigcommerce)===null||t===void 0?void 0:t.allowBypassQuery)===true};
|
|
252
|
+
/**
|
|
253
|
+
* Read an accepted `zBypass` query on the checkout page once, then remove it
|
|
254
|
+
* from the URL. A later call on that same URL returns the same answer.
|
|
255
|
+
*/var readCheckoutZBypassQuery=function(){var e=window.location,t=e.pathname,o=e.search;if(consumedZBypassQuery&&consumedZBypassQuery.pathname===t&&consumedZBypassQuery.search===o){return consumedZBypassQuery.enabled}var r=new URLSearchParams(o);var n=isAcceptedZBypassQuery(r.get("zBypass"));if(!n){consumedZBypassQuery={enabled:false,pathname:t,search:o};return false}r.delete("zBypass");var i=r.toString();var s=window.location.hash||"";var a="".concat(t).concat(i?"?".concat(i):"").concat(s);window.history.replaceState(window.history.state,document.title,a);var c=isBypassQueryAllowed();consumedZBypassQuery={enabled:c,pathname:t,search:window.location.search};return c};
|
|
256
|
+
/**
|
|
257
|
+
* True when this BigCommerce checkout page should skip address detection.
|
|
258
|
+
* That is only when zonos-settings allows the `zBypass` query and this
|
|
259
|
+
* checkout URL has an accepted value. Storefront pages are never bypassed, so
|
|
260
|
+
* the query stays in the URL until checkout. The query is removed once, and
|
|
261
|
+
* later calls on that checkout URL keep the same answer. Nothing is written
|
|
262
|
+
* to storage.
|
|
263
|
+
*/var isBigCommerceCheckoutBypassEnabled=function(){var e;if(!((e=window.Zonos)===null||e===void 0?void 0:e.isBigCommerce)||!isCheckoutPage()){return false}return readCheckoutZBypassQuery()};var FALLBACK_SHIP_TO_COUNTRY_SELECTOR='select[name="shippingAddress.countryCode"]';
|
|
243
264
|
/**
|
|
244
265
|
* Native BigCommerce shipping-step "Continue" button. Clicking it commits the
|
|
245
266
|
* selected shipping address and advances to the payment step.
|
|
@@ -262,6 +283,10 @@ window.location.href=buildBigcommerceRedirectUrl("/");return[2/*return*/,"redire
|
|
|
262
283
|
* Watch for changes in domestic checkout step. Redirects user to home page to open international checkout when user selects a country in the international shipping zone.
|
|
263
284
|
* @note Only works on default bigcommerce checkout page
|
|
264
285
|
*/var watchImmediateBigcommerceDomesticCheckoutRedirect=function(e){var t=e.domesticRedirectedBtnSelector,o=e.onInternationalCheckoutSelected,r=e.onLoggedInInternationalAddressDetected,n=e.onShippingAddressSessionFound;if(!window.Zonos.isBigCommerce){return}
|
|
286
|
+
// Only the native checkout page skips address detection. Storefront pages
|
|
287
|
+
// still run the domestic-session handoff below, and they do not consume
|
|
288
|
+
// a `zBypass` query, so the parameter can survive until `/checkout`.
|
|
289
|
+
if(window.location.pathname.includes("/checkout")&&isBigCommerceCheckoutBypassEnabled()){return}
|
|
265
290
|
/**
|
|
266
291
|
* Keep checking.
|
|
267
292
|
* @returns `true` if the caller should stop polling — either because the user
|
|
@@ -370,13 +395,13 @@ t.preventDefault();t.stopImmediatePropagation();void u(r,e)}),true)};var d=false
|
|
|
370
395
|
// `handleInternationalCheckoutSelected` (both consult the helper), so the
|
|
371
396
|
// top-level gate is redundant. `initBigCommerceBypassCheck()` is called on
|
|
372
397
|
// page load so those inner calls typically resolve against a warm cache.
|
|
373
|
-
var g=new MutationObserver((function(){return __awaiter(void 0,void 0,void 0,(function(){var e,s,a,c,u,p,S,C,k,
|
|
398
|
+
var g=new MutationObserver((function(){return __awaiter(void 0,void 0,void 0,(function(){var e,s,a,c,u,p,S,C,k,w;return __generator(this,(function(z){switch(z.label){case 0:s=document.querySelector(t);a=stripeStoreGetDomesticShippingSession();
|
|
374
399
|
// append a hidden button to the body if the shipping address session is found
|
|
375
400
|
if(!s&&a){c=document.createElement("button");c.style.display="none";c.id="zonos--domestic-redirected-checkout-button";document.body.appendChild(c);n===null||n===void 0?void 0:n(a);
|
|
376
401
|
// disconnect the observer after we found the shipping continue button
|
|
377
402
|
g.disconnect();return[2/*return*/]}u=window.location.pathname.includes("/checkout")&&window.Zonos.isBigCommerce;
|
|
378
403
|
// Should just disconnect the observer if it's not bigcommerce domestic checkout page
|
|
379
|
-
if(!u){g.disconnect();return[2/*return*/]}if(!(!v&&!f))return[3/*break*/,5];f=true;m=true;
|
|
404
|
+
if(!u){g.disconnect();return[2/*return*/]}if(!(!v&&!f))return[3/*break*/,5];f=true;m=true;z.label=1;case 1:z.trys.push([1,3,4,5]);return[4/*yield*/,checkLoggedInUserShippingAddress({onInternationalCheckoutSelected:o,onLoggedInInternationalAddressDetected:r})];case 2:p=z.sent();if(p==="redirected"){g.disconnect();return[2/*return*/]}if(p==="optedOut"){
|
|
380
405
|
// User elected to stay on BC native checkout — don't prompt again
|
|
381
406
|
// for the rest of this session. Continue with the rest of the
|
|
382
407
|
// observer logic so the country-change watcher still fires when
|
|
@@ -385,7 +410,7 @@ v=true;
|
|
|
385
410
|
// Attach the "Continue" redirect hook now (once). Delegation on
|
|
386
411
|
// `document` keeps it working even after this observer disconnects
|
|
387
412
|
// when the country <select> path sets up its interval below.
|
|
388
|
-
l(g)}return[3/*break*/,5];case 3:S=
|
|
413
|
+
l(g)}return[3/*break*/,5];case 3:S=z.sent();logError("Error checking logged-in user shipping address",S);return[3/*break*/,5];case 4:f=false;m=false;return[7/*endfinally*/];case 5:C=document.querySelector(((e=zonosStore.genericSettings)===null||e===void 0?void 0:e.bigcommerceDomesticCheckoutCountrySelector)||FALLBACK_SHIP_TO_COUNTRY_SELECTOR);
|
|
389
414
|
// Shouldn't do anything if it's not bigcommerce domestic checkout page
|
|
390
415
|
if(!C){
|
|
391
416
|
// do nothing if shipping country and the continue button is not found
|
|
@@ -400,7 +425,7 @@ if(d||m){return[2/*return*/]}d=true;o.label=1;case 1:o.trys.push([1,3,,4]);retur
|
|
|
400
425
|
// Stop the interval once either:
|
|
401
426
|
// - the user is being redirected to Zonos international checkout
|
|
402
427
|
// - the logged-in customer is in a bypass group (stay on BC checkout)
|
|
403
|
-
if(e==="redirected"||e==="bypass"){clearInterval(k);return[2/*return*/]}d=false;return[3/*break*/,4];case 3:t=o.sent();d=false;return[3/*break*/,4];case 4:return[2/*return*/]}}))}))}),1e3);
|
|
428
|
+
if(e==="redirected"||e==="bypass"){clearInterval(k);return[2/*return*/]}d=false;return[3/*break*/,4];case 3:t=o.sent();d=false;return[3/*break*/,4];case 4:return[2/*return*/]}}))}))}),1e3);w=setInterval((function(){var e;if(!window.bcStripeElements){clearInterval(w);return}var t=(e=window.bcStripeElements)===null||e===void 0?void 0:e.getElement("address");if(!t){return}clearInterval(w);t.on("change",(function(e){var t=e.value.address.country;if(t&&!m){void i(t)}}));
|
|
404
429
|
// we want to attacch event to addressElement as soon as it's loaded
|
|
405
430
|
}),500);return[2/*return*/]}}))}))}));g.observe(document.body,{childList:true,subtree:true})};var getLegacyQueryParams=function(){var e=new URLSearchParams(window.location.search);log("legacy urlParams","info",Object.fromEntries(e.entries()));var t=function(t){var o=e.get(t);if(!o||o==="undefined"){return""}return o};var o=
|
|
406
431
|
// fallback to selected country code if country is not provided
|
|
@@ -704,7 +729,7 @@ var i=document.querySelectorAll(n.join(","));
|
|
|
704
729
|
// only attach event once, and looping through all of the button elements
|
|
705
730
|
i.forEach((function(r){var n=r.getAttribute("data-zonos-checkout-attached");if(n){
|
|
706
731
|
// do nothing if event is already attached
|
|
707
|
-
return}log("attached event to button ".concat(t),"info",{button:r});r.addEventListener("click",(function(t){return __awaiter(e,void 0,void 0,(function(){var e,n,i,s,a,c,u,l,d,h,f,v,m,g,p,S,C,k,z
|
|
732
|
+
return}log("attached event to button ".concat(t),"info",{button:r});r.addEventListener("click",(function(t){return __awaiter(e,void 0,void 0,(function(){var e,n,i,s,a,c,u,l,d,h,f,v,m,g,p,S,C,k,w,z;return __generator(this,(function(y){switch(y.label){case 0:i=performance.now();s=o&&r.matches(o);a=r.matches("#".concat(checkoutHiddenInternationalBtnSelector));c=r.matches("#".concat(domesticRedirectedBtnSelector))||r.matches("#".concat(checkoutHiddenBtnSelector));
|
|
708
733
|
// Allow no country set for legacy facades. Otherwise enforce it being a shippable country and not disabled.
|
|
709
734
|
if(!window.Zonos.isLegacyCheckout&&(!isShippableCountry()||isDisabledCountry())&&!s&&!a&&!c){return[2/*return*/]}t.preventDefault();t.stopPropagation();log("zonos checkout button clicked");return[4/*yield*/,this.checkStripePaymentIntentStatus({triggeredButton:t.target})];case 1:u=y.sent().shouldAllowOrder;
|
|
710
735
|
// Only allow order to proceed if payment intent is not succeeded
|
|
@@ -735,11 +760,11 @@ cartStore.inventoryCheckErrorMessage=v;stripeStore.isFetchingSession=false;this.
|
|
|
735
760
|
// start the timer to validate the price
|
|
736
761
|
cartStoreStartCheckoutInterval({isPreview:this.preview,sessionTimeout:CHECKOUT_SESSION_TIMEOUT});submitAnalytics({event:"zonos-checkout-start",metadata:{checkoutSessionId:storageStore.checkoutSessionId}});g=storageStore.checkoutSessionId;void trackConversionEvent({checkoutSessionId:g,eventName:"checkout_open"});return[4/*yield*/,isStoreDiscountEnabled()];case 15:p=y.sent().enabled;
|
|
737
762
|
// Hide discount input if there's no active discount configured for the store
|
|
738
|
-
cartStore.shouldHideDiscountInput=!p;this.handleOrderDuplication();if(window.Zonos.isLegacyCheckout){void sendLoadCheckoutFacadeLog()}else{S=performance.now();C=S-i;void sendLoadNativeCheckoutLog({loadTime:C})}this.recordCheckoutInfo();k=!!getAbandonedCartRenewTokenValue();if(k){this.markTheSessionAsAbandonedCart()}return[3/*break*/,17];case 16:
|
|
763
|
+
cartStore.shouldHideDiscountInput=!p;this.handleOrderDuplication();if(window.Zonos.isLegacyCheckout){void sendLoadCheckoutFacadeLog()}else{S=performance.now();C=S-i;void sendLoadNativeCheckoutLog({loadTime:C})}this.recordCheckoutInfo();k=!!getAbandonedCartRenewTokenValue();if(k){this.markTheSessionAsAbandonedCart()}return[3/*break*/,17];case 16:w=y.sent();if(w instanceof Error){z=w.message;if(z==="Cart is expired."){this.isCartExpired=true}}
|
|
739
764
|
// stop loading
|
|
740
|
-
stripeStore.isFetchingSession=false;logError(
|
|
765
|
+
stripeStore.isFetchingSession=false;logError(w);if(this.isCartExpired){stripeStore.isFetchingSession=true;return[2/*return*/]}
|
|
741
766
|
// We want to log the error anytime we fail to create a checkout session
|
|
742
|
-
void sendErrorLog({endpoint:"Error creating Checkout",errors:[
|
|
767
|
+
void sendErrorLog({endpoint:"Error creating Checkout",errors:[w instanceof Error?w.toString():"Unknown error"],metadata:{allLogs:allLogs,cartId:window.Zonos.cartId,checkoutSessionBody:getCheckoutSessionBody(),href:window.location.href,storeBaseUrl:((n=window.Zonos.cartData)===null||n===void 0?void 0:n.storeBaseUrl)||zonosStore.onlineStoreSettings.url}});cartStoreUpdateToErrorState({messages:[translate("There's been an error creating your checkout session. Please reload and try again or contact support if the error persists")],title:translate("Error creating Checkout")});return[3/*break*/,17];case 17:return[2/*return*/]}}))}))}),{
|
|
743
768
|
// Trigger this event before any other event
|
|
744
769
|
capture:true,passive:false});if(!zonosStore.checkoutSettings.disablePlaceOrderButtonActivation){r.removeAttribute("disabled")}r.setAttribute("data-zonos-checkout-attached","true");
|
|
745
770
|
// if this button is the hidden button, trigger the click event
|
|
@@ -1000,13 +1025,13 @@ var s=cartStoreIsOrderModificationPaymentOnlySession();var a=mergeConfig(zonosSt
|
|
|
1000
1025
|
// use right side theme if it's mobile, otherwise use themePrimaryColorBased
|
|
1001
1026
|
var g=this.isMobile?v:m;
|
|
1002
1027
|
// only use submit button color if it's on desktop
|
|
1003
|
-
var p=!this.isMobile?u:undefined;var S=localizationStore.customMessages;var C=(t=S.find((function(e){return e.pageName==="checkout_default"})))===null||t===void 0?void 0:t.message;var k=this.getCurrentLocalePageEnum();var
|
|
1028
|
+
var p=!this.isMobile?u:undefined;var S=localizationStore.customMessages;var C=(t=S.find((function(e){return e.pageName==="checkout_default"})))===null||t===void 0?void 0:t.message;var k=this.getCurrentLocalePageEnum();var w=S.filter((function(e){return e.pageName===k}));
|
|
1004
1029
|
|
|
1005
|
-
var
|
|
1030
|
+
var z=this.getBaseCurrencySettlementInfo();var y=function(){
|
|
1006
1031
|
// add timestamp to logo url if it's preview mode so browser won't cache it on the dashboard setting
|
|
1007
1032
|
var t=e.preview?"".concat(l,"?timestamp=").concat(Date.now()):l;return h("div",{class:"zonos--logo"},t&&h("img",{alt:"".concat(zonosStore.organizationName," logo"),src:t}))};var _=getIsTestMode();var b=function(){var t=new URLSearchParams(window.location.search);var o=t.get("zonosQaUrl");var r=t.get("zonosDebug");var n=t.get("zonosE2ETest");var i=e.overrideStagingMode||getIsStagingMode();return h("zonos-v-stack",null,h("div",{class:"zonos--logo-wrapper"},y(),_&&h("zonos-badge",{badgeColor:"orange",size:"small"},translate("Test mode")),i&&h("zonos-badge",{badgeColor:"red",size:"small"},translate("Staging mode")),r==="1"&&h("zonos-badge",{badgeColor:"cyan",size:"small"},"debug"),o&&h("zonos-badge",{badgeColor:"purple",size:"small"},o),n&&h("zonos-badge",{badgeColor:"gray",size:"small"},"E2E Test")),!s&&h("zonos-checkout-progress-tabs",{backgroundColor:
|
|
1008
1033
|
// only use different contrast color when the secondary color is too off with the background in mobile
|
|
1009
|
-
e.isMobile?"--zonos-elements-gray-0":null}),
|
|
1034
|
+
e.isMobile?"--zonos-elements-gray-0":null}),w.map((function(e){return h("zonos-custom-message",{icon:MessageIcon,message:e.message})})))};var T=function(){if(cartStore.checkoutSessionTimeoutShow){return h("zonos-rest-state",{class:"zonos--session-timeout",restStateSubtitle:translate("Your checkout session has expired. Please reload the page to continue."),restStateTitle:translate("Session timed out"),restStateType:"Warning"},h("zonos-button",{onClick:function(){return e.reloadCheckoutSession()},variant:"primary"},translate("Reload")))}return h("div",{class:"zonos--content",style:{"--zonos--border-radius":getBorderRadius({overrideBorderStyle:d})}},cartStore.step!=="finish"&&cartStore.step!=="error"&&h(Fragment,null,h("div",{class:"zonos--left","data-theme":g,style:styles({"--zonos--primary-color":!e.isMobile?c:undefined})},!e.isMobile&&b(),cartStore.step==="customer-info"&&h("zonos-customer-info",{continueLoading:e.submitLoading,defaultAddress:e.getDefaultAddress(),isMobile:e.isMobile,onContinueClicked:function(){return e.handleCustomerInfoContinue()},submitBtnColor:p}),cartStore.step==="shipping"&&h("zonos-shipping",{continueLoading:e.submitLoading,isMobile:e.isMobile,onContinueClicked:function(){return e.handleShippingContinue()},submitBtnColor:p}),cartStore.step==="payment"&&h("zonos-checkout-payment",{continueLoading:e.submitLoading,isMobile:e.isMobile,onContinueClicked:function(){return __awaiter(e,void 0,void 0,(function(){return __generator(this,(function(e){switch(e.label){case 0:return[4/*yield*/,this.handleStripePaymentContinue()];case 1:e.sent();return[2/*return*/]}}))}))},submitBtnColor:p})),h("div",{class:"zonos--right","data-theme":v},e.isMobile&&b(),h("div",{class:"zonos--right-actions"},window.Zonos.showBaseForeign&&h("zonos-currency-toggle",null),!e.isLegacyCheckout&&h("zonos-button",{class:"zonos--close-button",icon:h("zonos-icon",{"aria-label":"Close checkout dialog",content:RemoveIcon}),noBackground:true,onClick:function(){return e.closeDialogHandler()}})),h("div",{class:"flex--wrapper"},h("div",{class:"zonos--wrapper"},h("zonos-review",{collapsed:e.collapseReviewMobile,mobile:e.isMobile,onClick:function(){
|
|
1010
1035
|
// do nothing if it's not mobile
|
|
1011
1036
|
if(!e.isMobile){return}e.collapseReviewMobile=!e.collapseReviewMobile}}),h("zonos-collapse",{
|
|
1012
1037
|
// only collapsible on mobile
|
|
@@ -1032,7 +1057,7 @@ dialogOpen:!!cartStore.inventoryCheckErrorMessage,
|
|
|
1032
1057
|
// If dialog is in open state, the message should not be null
|
|
1033
1058
|
dialogSubtitle:cartStore.inventoryCheckErrorMessage,dialogTitle:translate("Couldn't place order"),dialogType:"alert",
|
|
1034
1059
|
// Mark user selected confirm to close the dialog
|
|
1035
|
-
onConfirmClicked:function(){return e.handleInventoryCheckDialogConfirm()}}),
|
|
1060
|
+
onConfirmClicked:function(){return e.handleInventoryCheckDialogConfirm()}}),z&&h("zonos-confirm-dialog",{class:"zonos--pay-in-usd-dialog",dialogCancelBtnText:translate("Cancel"),dialogConfirmBtnText:translate("Pay [orderTotal]",{orderTotal:currencyFormat({amount:z.settlementAmount,currency:"USD"})}),dialogIntent:"warn",dialogOpen:this.payInUsdConfirmDialogOpen,dialogSubtitle:translate("By paying in USD, your card will be charged directly with no currency conversion. However, using a non-USD based card may result in additional currency conversion fees at the bank level."),dialogTitle:translate("Pay in USD (United States Dollar)?"),dialogType:"confirm",dialogWidth:480,onCancelClicked:function(){e.payInUsdConfirmDialogOpen=false},
|
|
1036
1061
|
// Mark user selected confirm to continue with payment
|
|
1037
1062
|
onConfirmClicked:function(){return e.handleStripePaymentContinue()}}),h("zonos-confirm-dialog",{class:"zonos--shopping-cart-expired-dialog",dialogConfirmBtnText:translate("OK"),dialogIntent:"danger",
|
|
1038
1063
|
// Show dialog if inventory check error message is not null
|
package/dist/scripts/index.d.ts
CHANGED
|
@@ -8314,6 +8314,20 @@ type CheckoutConfig = {
|
|
|
8314
8314
|
* @default TEST
|
|
8315
8315
|
*/
|
|
8316
8316
|
mode: Mode;
|
|
8317
|
+
/**
|
|
8318
|
+
* Platform plugins. BigCommerce `allowBypassQuery` comes from the
|
|
8319
|
+
* zonos-settings response. The storefront does not default it on.
|
|
8320
|
+
*/
|
|
8321
|
+
plugins?: {
|
|
8322
|
+
bigcommerce?: {
|
|
8323
|
+
/**
|
|
8324
|
+
* When `true`, a `zBypass` query on the BigCommerce checkout page skips
|
|
8325
|
+
* address detection for that page load. The parameter is removed from the
|
|
8326
|
+
* URL after it is read. `false` or omitted ignores the parameter.
|
|
8327
|
+
*/
|
|
8328
|
+
allowBypassQuery?: boolean;
|
|
8329
|
+
};
|
|
8330
|
+
};
|
|
8317
8331
|
orderNotifications: {
|
|
8318
8332
|
abandonedCart: {
|
|
8319
8333
|
delay: number;
|