@zonos/elements 1.3.258 → 1.3.260
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-c618fd5b.js → cart-d08c87e2.js} +1 -1
- package/dist/cjs/{hasInclusivePrice-58a9f15d.js → hasInclusivePrice-c781c336.js} +1 -1
- package/dist/cjs/index.cjs.js +7 -7
- package/dist/cjs/{invoice-c9cb6683.js → invoice-e64f97c6.js} +2 -2
- package/dist/cjs/{isCollectMobileTablet-93a5194a.js → isCollectMobileTablet-9675485f.js} +2 -2
- package/dist/cjs/{localization-5994d4de.js → localization-a7fac4b4.js} +3 -0
- package/dist/cjs/{paypal-091e089e.js → paypal-73a542cb.js} +2 -2
- package/dist/cjs/{placeTestOrder-b07f8edb.js → placeTestOrder-aefd31e8.js} +2 -2
- package/dist/cjs/{renderCheckoutCurrency-7876a1d4.js → renderCheckoutCurrency-a374741a.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 +442 -17
- 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 +8 -8
- package/dist/cjs/zonos-hello.cjs.entry.js +1 -1
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +4 -4
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +6 -6
- package/dist/cjs/zonos-invoice.cjs.entry.js +4 -4
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +1 -1
- package/dist/cjs/zonos-store-credit.cjs.entry.js +3 -3
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +72 -0
- package/dist/collection/components/hello/zonos-hello-dialog/zonos-hello-dialog.js +6 -6
- package/dist/collection/components/store/hello/localization.js +3 -0
- package/dist/collection/components/utils/checkout/bigcommerceStorefrontApi.js +6 -0
- package/dist/collection/components/utils/checkout/buildBigcommerceLoginUrl.js +65 -0
- package/dist/collection/components/utils/checkout/checkBigCommerceBypassCustomerGroup.js +12 -7
- package/dist/collection/components/utils/checkout/checkBigCommerceForceLogin.js +116 -0
- package/dist/collection/components/utils/checkout/fetchBigCommerceCheckoutSettings.js +92 -0
- package/dist/collection/components/utils/checkout/fixBigCommerceLoginCreateAccountLink.js +53 -0
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +40 -7
- package/dist/collection/types/checkout/api/BigCommerceCheckoutSettings.js +1 -0
- package/dist/collection/types/generated/graphql.frontend.types.js +2 -0
- package/dist/collection/types/generated/graphql.internal.types.js +39 -0
- package/dist/collection/types/index.js +1 -0
- package/dist/esm/{cart-76fb528f.js → cart-c490d252.js} +1 -1
- package/dist/esm/{hasInclusivePrice-275b1048.js → hasInclusivePrice-7a0ce66a.js} +1 -1
- package/dist/esm/index.js +7 -7
- package/dist/esm/{invoice-9efcb941.js → invoice-3ea5715b.js} +2 -2
- package/dist/esm/{isCollectMobileTablet-a7e5b909.js → isCollectMobileTablet-0dcbd45a.js} +2 -2
- package/dist/esm/{localization-76ce3e29.js → localization-542dbe20.js} +3 -0
- package/dist/esm/{paypal-75c5c66d.js → paypal-38ca5d21.js} +2 -2
- package/dist/esm/{placeTestOrder-22633bf2.js → placeTestOrder-d7001709.js} +2 -2
- package/dist/esm/{renderCheckoutCurrency-d27b0082.js → renderCheckoutCurrency-75f1bba3.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 +443 -18
- 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 +8 -8
- package/dist/esm/zonos-hello.entry.js +1 -1
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +4 -4
- package/dist/esm/zonos-invoice-finish_5.entry.js +6 -6
- package/dist/esm/zonos-invoice.entry.js +4 -4
- package/dist/esm/zonos-language-select_2.entry.js +1 -1
- package/dist/esm/zonos-store-credit.entry.js +3 -3
- package/dist/esm-es5/{cart-76fb528f.js → cart-c490d252.js} +1 -1
- package/dist/esm-es5/{hasInclusivePrice-275b1048.js → hasInclusivePrice-7a0ce66a.js} +1 -1
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/{invoice-9efcb941.js → invoice-3ea5715b.js} +1 -1
- package/dist/esm-es5/{isCollectMobileTablet-a7e5b909.js → isCollectMobileTablet-0dcbd45a.js} +1 -1
- package/dist/esm-es5/{localization-76ce3e29.js → localization-542dbe20.js} +1 -1
- package/dist/esm-es5/{paypal-75c5c66d.js → paypal-38ca5d21.js} +2 -2
- package/dist/esm-es5/{placeTestOrder-22633bf2.js → placeTestOrder-d7001709.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-d27b0082.js → renderCheckoutCurrency-75f1bba3.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-store-credit.entry.js +1 -1
- package/dist/scripts/index.d.ts +21 -5
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/checkout/zonos-checkout/zonos-checkout.d.ts +16 -0
- package/dist/types/components/utils/api/getLocaleMessages.d.ts +1 -1
- package/dist/types/components/utils/checkout/bigcommerceStorefrontApi.d.ts +6 -0
- package/dist/types/components/utils/checkout/buildBigcommerceLoginUrl.d.ts +27 -0
- package/dist/types/components/utils/checkout/checkBigCommerceBypassCustomerGroup.d.ts +12 -0
- package/dist/types/components/utils/checkout/checkBigCommerceForceLogin.d.ts +50 -0
- package/dist/types/components/utils/checkout/fetchBigCommerceCheckoutSettings.d.ts +18 -0
- package/dist/types/components/utils/checkout/fixBigCommerceLoginCreateAccountLink.d.ts +17 -0
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +6 -5
- package/dist/types/types/checkout/CheckoutConfig.d.ts +9 -0
- package/dist/types/types/checkout/api/BigCommerceCheckoutSettings.d.ts +12 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +3 -1
- package/dist/types/types/generated/graphql.frontend.types.ts +3 -1
- package/dist/types/types/generated/graphql.internal.types.d.ts +58 -9
- package/dist/types/types/generated/graphql.internal.types.ts +69 -9
- package/dist/types/types/index.d.ts +1 -0
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-6d36b307.system.js → p-0699931c.system.js} +1 -1
- package/dist/zonos-elements/{p-29d16ad0.entry.js → p-0ad75f38.entry.js} +1 -1
- package/dist/zonos-elements/{p-e6168c82.system.js → p-0ec4e307.system.js} +1 -1
- package/dist/zonos-elements/p-0f89fc76.system.entry.js +1 -0
- package/dist/zonos-elements/{p-4b138a6e.system.entry.js → p-0fc5a2cc.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-2ec799e4.system.js → p-196423ad.system.js} +1 -1
- package/dist/zonos-elements/{p-567abb43.system.js → p-20263609.system.js} +1 -1
- package/dist/zonos-elements/{p-a89096d6.system.entry.js → p-20842d8c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-bdb3f7a2.js → p-24407504.js} +2 -2
- package/dist/zonos-elements/{p-1523f6a8.system.js → p-248bdea2.system.js} +1 -1
- package/dist/zonos-elements/{p-a4b6865d.system.entry.js → p-266a86d4.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-bba9af4c.entry.js → p-27f01d76.entry.js} +1 -1
- package/dist/zonos-elements/p-29b60bf3.system.js +1 -1
- package/dist/zonos-elements/{p-b34f1336.system.entry.js → p-2ac0fcb8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-5fa3d1c8.system.entry.js → p-2c9714e8.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-edb0306c.system.entry.js → p-365d4481.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-7157a5a3.entry.js → p-3a198386.entry.js} +1 -1
- package/dist/zonos-elements/{p-1e9e284e.system.entry.js → p-3e7dbe9c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-99d92a84.entry.js → p-4416fe27.entry.js} +1 -1
- package/dist/zonos-elements/{p-e8a68ce7.system.js → p-47bde0ba.system.js} +1 -1
- package/dist/zonos-elements/p-4aa5f5db.entry.js +1 -0
- package/dist/zonos-elements/{p-afdb4445.entry.js → p-5be87ae0.entry.js} +1 -1
- package/dist/zonos-elements/p-6b7beb44.system.js +1 -0
- package/dist/zonos-elements/{p-e5f48239.system.entry.js → p-70e2f9f9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3ee8496e.js → p-7158a18b.js} +1 -1
- package/dist/zonos-elements/{p-867d05d7.system.js → p-720ae42c.system.js} +1 -1
- package/dist/zonos-elements/p-721fadd5.js +1 -0
- package/dist/zonos-elements/{p-24f41959.js → p-72adb40d.js} +1 -1
- package/dist/zonos-elements/p-7c5c5318.js +1 -0
- package/dist/zonos-elements/{p-9c97671b.system.entry.js → p-874ccf1c.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-0a9741f7.entry.js → p-87eef44c.entry.js} +1 -1
- package/dist/zonos-elements/{p-6cf8fe49.system.entry.js → p-8d0bca3a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9a9c9441.system.entry.js → p-8d52ac69.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-791e13e7.entry.js → p-8dae0f0b.entry.js} +1 -1
- package/dist/zonos-elements/{p-6e50f6f5.entry.js → p-8df3c6a0.entry.js} +1 -1
- package/dist/zonos-elements/{p-5182e492.entry.js → p-9dc671f4.entry.js} +1 -1
- package/dist/zonos-elements/{p-2d854a75.entry.js → p-a3020bc9.entry.js} +1 -1
- package/dist/zonos-elements/{p-a18adf27.js → p-a75b8ad7.js} +1 -1
- package/dist/zonos-elements/{p-bd938f80.js → p-a8bb461c.js} +1 -1
- package/dist/zonos-elements/{p-2b2b1c8c.system.entry.js → p-b21cf539.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1ebb59a3.js → p-b5223840.js} +1 -1
- package/dist/zonos-elements/{p-10da499b.system.entry.js → p-bf4d2299.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-425f747b.entry.js → p-c09540bc.entry.js} +1 -1
- package/dist/zonos-elements/{p-1661f938.entry.js → p-c308c5bc.entry.js} +1 -1
- package/dist/zonos-elements/{p-9460919d.entry.js → p-cdf99051.entry.js} +1 -1
- package/dist/zonos-elements/{p-788c6839.entry.js → p-d12fa775.entry.js} +1 -1
- package/dist/zonos-elements/{p-055c8d6c.system.entry.js → p-d2ef0416.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-afca19b0.system.entry.js → p-d4f9e464.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-3600280d.system.js → p-d7a9be55.system.js} +1 -1
- package/dist/zonos-elements/{p-5262f6e8.entry.js → p-da5a35a6.entry.js} +1 -1
- package/dist/zonos-elements/{p-8585c761.system.entry.js → p-df240101.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-14d35979.system.entry.js → p-df578aa9.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9cff66a7.entry.js → p-e684e68f.entry.js} +1 -1
- package/dist/zonos-elements/{p-a0f6910c.entry.js → p-f2a74e43.entry.js} +1 -1
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/zonos-elements/p-50b32476.system.entry.js +0 -1
- package/dist/zonos-elements/p-733f118d.entry.js +0 -1
- package/dist/zonos-elements/p-868a8667.js +0 -1
- package/dist/zonos-elements/p-c85e988d.system.js +0 -1
- package/dist/zonos-elements/p-ed03b7fd.js +0 -1
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const paypal = require('./paypal-
|
|
8
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-d08c87e2.js');
|
|
7
|
+
const paypal = require('./paypal-73a542cb.js');
|
|
8
|
+
const localization = require('./localization-a7fac4b4.js');
|
|
9
9
|
const zonosStore = require('./zonosStore-1c517e55.js');
|
|
10
10
|
const buildCartItemsByTempCart = require('./buildCartItemsByTempCart-edddbf4b.js');
|
|
11
11
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
@@ -97,6 +97,71 @@ const buildCartUrl = ({ cartId, checkoutSessionId, customerAddress1, customerAdd
|
|
|
97
97
|
return `${hostedCheckoutUrl}?${urlParams.toString()}`;
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* The query flag that BigCommerce carries back to `cart.php` after the
|
|
102
|
+
* shopper logs in. When present, Zonos-elements knows to resume the
|
|
103
|
+
* international checkout flow instead of letting BC's native cart UX
|
|
104
|
+
* take over.
|
|
105
|
+
*/
|
|
106
|
+
const BIGCOMMERCE_INTERNATIONAL_CHECKOUT_FLAG = 'isInternationalCheckout';
|
|
107
|
+
/**
|
|
108
|
+
* Build the `from` query value handed to BigCommerce's `/login.php` so that
|
|
109
|
+
* after a successful login the shopper lands back on `cart.php` with the
|
|
110
|
+
* `isInternationalCheckout=true` flag set (plus any `zonosTestMode` /
|
|
111
|
+
* `zonosQaUrl` / `zonosQaUrlApi` that were on the current URL, so the
|
|
112
|
+
* preview build / API host / test credentials carry through the round trip).
|
|
113
|
+
*/
|
|
114
|
+
const buildFromCartPath = () => {
|
|
115
|
+
const params = new URLSearchParams();
|
|
116
|
+
params.set(BIGCOMMERCE_INTERNATIONAL_CHECKOUT_FLAG, 'true');
|
|
117
|
+
const currentParams = new URLSearchParams(window.location.search);
|
|
118
|
+
const zonosQaUrl = currentParams.get('zonosQaUrl');
|
|
119
|
+
if (zonosQaUrl) {
|
|
120
|
+
params.set('zonosQaUrl', zonosQaUrl);
|
|
121
|
+
}
|
|
122
|
+
const zonosQaUrlApi = currentParams.get('zonosQaUrlApi');
|
|
123
|
+
if (zonosQaUrlApi) {
|
|
124
|
+
params.set('zonosQaUrlApi', zonosQaUrlApi);
|
|
125
|
+
}
|
|
126
|
+
if (handleFetch.getIsTestMode()) {
|
|
127
|
+
params.set('zonosTestMode', '1');
|
|
128
|
+
}
|
|
129
|
+
return `cart.php?${params.toString()}`;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Build an absolute URL to BigCommerce's `/login.php` with the
|
|
133
|
+
* `from=cart.php?isInternationalCheckout=true` round-trip encoded so the
|
|
134
|
+
* shopper resumes Zonos international checkout after authenticating.
|
|
135
|
+
*
|
|
136
|
+
* Preserves `zonosTestMode` / `zonosQaUrl` / `zonosQaUrlApi` from the current
|
|
137
|
+
* URL across the redirect — the login round trip leaves BC's frontend, so
|
|
138
|
+
* without this the returning `cart.php` would drop back to the production
|
|
139
|
+
* build / API host.
|
|
140
|
+
*/
|
|
141
|
+
const buildBigcommerceLoginUrl = ({ action } = {}) => {
|
|
142
|
+
const url = new URL('/login.php', window.location.origin);
|
|
143
|
+
if (action) {
|
|
144
|
+
url.searchParams.set('action', action);
|
|
145
|
+
}
|
|
146
|
+
const currentParams = new URLSearchParams(window.location.search);
|
|
147
|
+
// set zonosQaUrl from the current URL
|
|
148
|
+
const zonosQaUrl = currentParams.get('zonosQaUrl');
|
|
149
|
+
if (zonosQaUrl) {
|
|
150
|
+
url.searchParams.set('zonosQaUrl', zonosQaUrl);
|
|
151
|
+
}
|
|
152
|
+
// set zonosQaUrlApi from the current URL
|
|
153
|
+
const zonosQaUrlApi = currentParams.get('zonosQaUrlApi');
|
|
154
|
+
if (zonosQaUrlApi) {
|
|
155
|
+
url.searchParams.set('zonosQaUrlApi', zonosQaUrlApi);
|
|
156
|
+
}
|
|
157
|
+
// set zonosTestMode from the current URL
|
|
158
|
+
if (handleFetch.getIsTestMode()) {
|
|
159
|
+
url.searchParams.set('zonosTestMode', '1');
|
|
160
|
+
}
|
|
161
|
+
url.searchParams.set('from', buildFromCartPath());
|
|
162
|
+
return url.toString();
|
|
163
|
+
};
|
|
164
|
+
|
|
100
165
|
/**
|
|
101
166
|
* Build an absolute redirect URL used by the BigCommerce checkout flows to
|
|
102
167
|
* navigate between the BC native `/checkout` page and the Zonos international
|
|
@@ -169,6 +234,12 @@ const fetchBigCommerceCheckout = async (checkoutId) => {
|
|
|
169
234
|
return null;
|
|
170
235
|
}
|
|
171
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* Whether the BigCommerce shopper is already logged in. We key off the
|
|
239
|
+
* customer's numeric `id` since the storefront API populates it only for
|
|
240
|
+
* authenticated sessions (guest checkouts have an empty `customer` object).
|
|
241
|
+
*/
|
|
242
|
+
const isBigCommerceCustomerLoggedIn = (checkout) => { var _a; return !!((_a = checkout === null || checkout === void 0 ? void 0 : checkout.customer) === null || _a === void 0 ? void 0 : _a.id); };
|
|
172
243
|
|
|
173
244
|
const DEFAULT_RESULT = {
|
|
174
245
|
customerGroupId: null,
|
|
@@ -178,7 +249,7 @@ const DEFAULT_RESULT = {
|
|
|
178
249
|
* Performs the actual fetch logic to determine if the customer
|
|
179
250
|
* belongs to a bypass group.
|
|
180
251
|
*/
|
|
181
|
-
const fetchBypassOutcome = async () => {
|
|
252
|
+
const fetchBypassOutcome = async (preFetched) => {
|
|
182
253
|
var _a, _b, _c, _d;
|
|
183
254
|
// Only relevant for BigCommerce stores — permanent no-op on other platforms
|
|
184
255
|
if (!window.Zonos.isBigCommerce) {
|
|
@@ -195,8 +266,11 @@ const fetchBypassOutcome = async () => {
|
|
|
195
266
|
// Mark as inconclusive so a later caller retries after config loads.
|
|
196
267
|
return { conclusive: false, result: DEFAULT_RESULT };
|
|
197
268
|
}
|
|
198
|
-
// Fetch customer group from BigCommerce Storefront API
|
|
199
|
-
|
|
269
|
+
// Fetch customer group from BigCommerce Storefront API — or reuse
|
|
270
|
+
// caller-supplied data when available.
|
|
271
|
+
const checkoutId = preFetched
|
|
272
|
+
? preFetched.checkoutId
|
|
273
|
+
: await fetchCheckoutId();
|
|
200
274
|
if (!checkoutId) {
|
|
201
275
|
// No active cart yet — inconclusive. Common on fresh sessions where
|
|
202
276
|
// `initBigCommerceBypassCheck` runs before the user has added anything
|
|
@@ -204,7 +278,9 @@ const fetchBypassOutcome = async () => {
|
|
|
204
278
|
VarianceTest.log('BigCommerce bypass check: no active cart yet, will retry on next call', 'info');
|
|
205
279
|
return { conclusive: false, result: DEFAULT_RESULT };
|
|
206
280
|
}
|
|
207
|
-
const checkout =
|
|
281
|
+
const checkout = preFetched
|
|
282
|
+
? preFetched.checkout
|
|
283
|
+
: await fetchBigCommerceCheckout(checkoutId);
|
|
208
284
|
if (!checkout) {
|
|
209
285
|
// API call failed (network error, non-200, etc.) — inconclusive.
|
|
210
286
|
// Caching this would permanently disable bypass for the session if
|
|
@@ -238,8 +314,8 @@ const fetchBypassOutcome = async () => {
|
|
|
238
314
|
* cart or after settings finish loading).
|
|
239
315
|
*/
|
|
240
316
|
let bypassCheckPromise = null;
|
|
241
|
-
const startBypassCheck = () => {
|
|
242
|
-
const outcomePromise = fetchBypassOutcome();
|
|
317
|
+
const startBypassCheck = (preFetched) => {
|
|
318
|
+
const outcomePromise = fetchBypassOutcome(preFetched);
|
|
243
319
|
const resultPromise = outcomePromise.then(({ conclusive, result }) => {
|
|
244
320
|
if (!conclusive && bypassCheckPromise === resultPromise) {
|
|
245
321
|
// Invalidate cache so the next caller performs a fresh fetch.
|
|
@@ -285,11 +361,259 @@ const initBigCommerceBypassCheck = () => {
|
|
|
285
361
|
*/
|
|
286
362
|
const checkBigCommerceBypassCustomerGroup = async (options = {}) => {
|
|
287
363
|
if (options.forceRefresh || !bypassCheckPromise) {
|
|
288
|
-
return startBypassCheck();
|
|
364
|
+
return startBypassCheck(options.preFetched);
|
|
289
365
|
}
|
|
290
366
|
return bypassCheckPromise;
|
|
291
367
|
};
|
|
292
368
|
|
|
369
|
+
const EMPTY = { guestCheckoutType: null };
|
|
370
|
+
/**
|
|
371
|
+
* BigCommerce's `/checkouts/settings` values almost never change after a
|
|
372
|
+
* merchant's initial setup, so we persist the result in `localStorage` and
|
|
373
|
+
* reuse it across page loads up to this TTL. Short enough that if the
|
|
374
|
+
* merchant flips `guest_checkout_type` the change still propagates within
|
|
375
|
+
* an hour.
|
|
376
|
+
*/
|
|
377
|
+
const CACHE_TTL_MS = 60 * 60 * 1000;
|
|
378
|
+
const CACHE_KEY = 'zonos--bc-checkout-settings';
|
|
379
|
+
const readFromCache = (storeHash) => {
|
|
380
|
+
try {
|
|
381
|
+
const raw = window.localStorage.getItem(CACHE_KEY);
|
|
382
|
+
if (!raw) {
|
|
383
|
+
return null;
|
|
384
|
+
}
|
|
385
|
+
const parsed = handleFetch.jsonParse(raw);
|
|
386
|
+
if (!parsed) {
|
|
387
|
+
return null;
|
|
388
|
+
}
|
|
389
|
+
// Different store on the same origin (e.g. zonosQaUrl preview) — ignore.
|
|
390
|
+
if (parsed.storeHash !== storeHash) {
|
|
391
|
+
return null;
|
|
392
|
+
}
|
|
393
|
+
if (parsed.expiresAt < Date.now()) {
|
|
394
|
+
return null;
|
|
395
|
+
}
|
|
396
|
+
return { guestCheckoutType: parsed.guestCheckoutType };
|
|
397
|
+
}
|
|
398
|
+
catch (_a) {
|
|
399
|
+
// localStorage access can throw in blocked-storage contexts (Safari
|
|
400
|
+
// private mode, cross-origin iframes) — treat as a cache miss so the
|
|
401
|
+
// network fallback runs.
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
const writeToCache = (storeHash, result) => {
|
|
406
|
+
try {
|
|
407
|
+
const payload = {
|
|
408
|
+
expiresAt: Date.now() + CACHE_TTL_MS,
|
|
409
|
+
guestCheckoutType: result.guestCheckoutType,
|
|
410
|
+
storeHash,
|
|
411
|
+
};
|
|
412
|
+
window.localStorage.setItem(CACHE_KEY, JSON.stringify(payload));
|
|
413
|
+
}
|
|
414
|
+
catch (_a) {
|
|
415
|
+
// localStorage can be disabled / quota-exceeded in some browser contexts
|
|
416
|
+
// (private mode, cross-origin iframes) — drop silently since caching
|
|
417
|
+
// is only an optimization.
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* Fetch the merchant's BigCommerce `/checkouts/settings` (via the demo-app
|
|
422
|
+
* proxy) so we can inspect `guest_checkout_type` from the storefront. The
|
|
423
|
+
* Store API is auth-gated, which is why we don't call it directly.
|
|
424
|
+
*
|
|
425
|
+
* Results are cached in `localStorage` for `CACHE_TTL_MS` so navigations
|
|
426
|
+
* inside the same store don't all pay the proxy round trip — the setting
|
|
427
|
+
* is merchant-level and rarely changes.
|
|
428
|
+
*/
|
|
429
|
+
const fetchBigCommerceCheckoutSettings = async () => {
|
|
430
|
+
var _a;
|
|
431
|
+
if (!window.Zonos.isBigCommerce) {
|
|
432
|
+
return EMPTY;
|
|
433
|
+
}
|
|
434
|
+
const storeHash = (_a = zonosStore.zonosStore.checkoutSettings.bigCommerceConfig) === null || _a === void 0 ? void 0 : _a.storeHash;
|
|
435
|
+
if (!storeHash) {
|
|
436
|
+
VarianceTest.log('BigCommerce checkout settings: no storeHash provided — skipping fetch', 'info');
|
|
437
|
+
return EMPTY;
|
|
438
|
+
}
|
|
439
|
+
const cached = readFromCache(storeHash);
|
|
440
|
+
if (cached) {
|
|
441
|
+
return cached;
|
|
442
|
+
}
|
|
443
|
+
const { errors, json } = await handleFetch.handleFetch('/api/bigcommerce/checkout-settings', {
|
|
444
|
+
body: { storeHash },
|
|
445
|
+
method: 'POST',
|
|
446
|
+
});
|
|
447
|
+
if (errors.length || !json) {
|
|
448
|
+
VarianceTest.log('BigCommerce checkout settings: proxy call failed, falling back to guest-allowed behavior', 'info');
|
|
449
|
+
return EMPTY;
|
|
450
|
+
}
|
|
451
|
+
const result = {
|
|
452
|
+
guestCheckoutType: json.guestCheckoutType,
|
|
453
|
+
};
|
|
454
|
+
writeToCache(storeHash, result);
|
|
455
|
+
return result;
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
const SKIP = {
|
|
459
|
+
redirectUrl: null,
|
|
460
|
+
shouldForceLogin: false,
|
|
461
|
+
};
|
|
462
|
+
/**
|
|
463
|
+
* Session cache for the merchant-level "does BC require login?" answer.
|
|
464
|
+
* Hitting `/checkouts/settings` on every checkout open would add a visible
|
|
465
|
+
* round trip to the hot path, so we resolve it once and reuse — the setting
|
|
466
|
+
* is configured at the store level and very rarely changes.
|
|
467
|
+
*
|
|
468
|
+
* `null` means we haven't kicked off the fetch yet; the promise holds the
|
|
469
|
+
* eventual boolean so multiple concurrent callers deduplicate.
|
|
470
|
+
*/
|
|
471
|
+
let storeRequiresLoginPromise = null;
|
|
472
|
+
const resolveStoreRequiresLogin = () => {
|
|
473
|
+
if (!storeRequiresLoginPromise) {
|
|
474
|
+
const pending = fetchBigCommerceCheckoutSettings()
|
|
475
|
+
.then(({ guestCheckoutType }) => {
|
|
476
|
+
if (!guestCheckoutType) {
|
|
477
|
+
// `null` here means either the proxy call failed (transient) or the
|
|
478
|
+
// storeHash wasn't known yet. Fail open for this call, but clear
|
|
479
|
+
// the cached promise so the next caller retries instead of
|
|
480
|
+
// permanently disabling force-login for the rest of the session.
|
|
481
|
+
if (storeRequiresLoginPromise === pending) {
|
|
482
|
+
storeRequiresLoginPromise = null;
|
|
483
|
+
}
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
return guestCheckoutType === 'no_guest_checkout';
|
|
487
|
+
})
|
|
488
|
+
.catch(() => {
|
|
489
|
+
// Defense-in-depth: `fetchBigCommerceCheckoutSettings` is expected to
|
|
490
|
+
// swallow its own errors, but if anything above does reject we fail
|
|
491
|
+
// open and clear the cached promise so the next caller can retry.
|
|
492
|
+
if (storeRequiresLoginPromise === pending) {
|
|
493
|
+
storeRequiresLoginPromise = null;
|
|
494
|
+
}
|
|
495
|
+
return false;
|
|
496
|
+
});
|
|
497
|
+
storeRequiresLoginPromise = pending;
|
|
498
|
+
}
|
|
499
|
+
return storeRequiresLoginPromise;
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* Kick off the `/checkouts/settings` fetch in the background on page load
|
|
503
|
+
* so the result is warm by the time the shopper opens checkout. Safe to
|
|
504
|
+
* call more than once — re-invocations reuse the in-flight/resolved
|
|
505
|
+
* promise.
|
|
506
|
+
*/
|
|
507
|
+
const initBigCommerceForceLoginCheck = () => {
|
|
508
|
+
if (!window.Zonos.isBigCommerce) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
void resolveStoreRequiresLogin();
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* Decide whether the current BigCommerce shopper must sign in before the
|
|
515
|
+
* Zonos international checkout is allowed to open.
|
|
516
|
+
*
|
|
517
|
+
* Required conditions (all must hold):
|
|
518
|
+
* 1. Running on a BigCommerce storefront.
|
|
519
|
+
* 2. BC merchant has `guest_checkout_type === 'no_guest_checkout'` in their
|
|
520
|
+
* live `/v3/checkouts/settings` response.
|
|
521
|
+
* 3. Shopper has an active cart.
|
|
522
|
+
* 4. Shopper is not already logged in to BigCommerce.
|
|
523
|
+
*
|
|
524
|
+
* Returning a `redirectUrl` is an instruction, not an action: callers drive
|
|
525
|
+
* the navigation themselves so they can short-circuit any UI state (loading
|
|
526
|
+
* overlays, dialog open flags) before `window.location.href` flips.
|
|
527
|
+
*/
|
|
528
|
+
const checkBigCommerceForceLogin = async ({ preFetched, } = {}) => {
|
|
529
|
+
if (!window.Zonos.isBigCommerce) {
|
|
530
|
+
return SKIP;
|
|
531
|
+
}
|
|
532
|
+
const requiresLogin = await resolveStoreRequiresLogin();
|
|
533
|
+
if (!requiresLogin) {
|
|
534
|
+
return SKIP;
|
|
535
|
+
}
|
|
536
|
+
const checkoutId = preFetched
|
|
537
|
+
? preFetched.checkoutId
|
|
538
|
+
: await fetchCheckoutId();
|
|
539
|
+
if (!checkoutId) {
|
|
540
|
+
// No active cart — nothing to protect. Force-login only matters once
|
|
541
|
+
// the shopper has a cart we're about to carry into Zonos checkout.
|
|
542
|
+
return SKIP;
|
|
543
|
+
}
|
|
544
|
+
const checkout = preFetched
|
|
545
|
+
? preFetched.checkout
|
|
546
|
+
: await fetchBigCommerceCheckout(checkoutId);
|
|
547
|
+
if (!checkout) {
|
|
548
|
+
// Storefront API failure — fail open so a transient outage doesn't
|
|
549
|
+
// block the shopper. The merchant's BC checkout will still enforce
|
|
550
|
+
// login server-side as a last line of defense.
|
|
551
|
+
VarianceTest.log('BigCommerce force-login check: failed to fetch checkout data, allowing flow to continue', 'info');
|
|
552
|
+
return SKIP;
|
|
553
|
+
}
|
|
554
|
+
if (isBigCommerceCustomerLoggedIn(checkout)) {
|
|
555
|
+
return SKIP;
|
|
556
|
+
}
|
|
557
|
+
VarianceTest.log('BigCommerce force-login check: guest shopper on no-guest-checkout store, redirecting to /login.php', 'info');
|
|
558
|
+
return {
|
|
559
|
+
redirectUrl: buildBigcommerceLoginUrl(),
|
|
560
|
+
shouldForceLogin: true,
|
|
561
|
+
};
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Mark we've already rewritten a given anchor so the MutationObserver
|
|
566
|
+
* doesn't loop on its own mutation.
|
|
567
|
+
*/
|
|
568
|
+
const REWRITTEN_ATTR = 'data-zonos-login-from-rewritten';
|
|
569
|
+
const CREATE_ACCOUNT_SELECTOR = 'a[href*="login.php?action=create_account"]:not([' + REWRITTEN_ATTR + '])';
|
|
570
|
+
const rewriteCreateAccountLinks = () => {
|
|
571
|
+
const anchors = document.querySelectorAll(CREATE_ACCOUNT_SELECTOR);
|
|
572
|
+
if (!anchors.length) {
|
|
573
|
+
return;
|
|
574
|
+
}
|
|
575
|
+
const target = buildBigcommerceLoginUrl({ action: 'create_account' });
|
|
576
|
+
anchors.forEach(anchor => {
|
|
577
|
+
anchor.setAttribute('href', target);
|
|
578
|
+
anchor.setAttribute(REWRITTEN_ATTR, 'true');
|
|
579
|
+
});
|
|
580
|
+
};
|
|
581
|
+
/**
|
|
582
|
+
* On BigCommerce's `/login.php`, the default **Create account** button links
|
|
583
|
+
* to `login.php?action=create_account` without the `from=cart.php...`
|
|
584
|
+
* parameter that the shopper had when they arrived. Without this, completing
|
|
585
|
+
* signup would drop them on the account home page instead of resuming Zonos
|
|
586
|
+
* international checkout.
|
|
587
|
+
*
|
|
588
|
+
* This watcher finds any create-account anchor on the page (including ones
|
|
589
|
+
* that the BC theme renders later via Stencil bundle load) and rewrites the
|
|
590
|
+
* `href` so the account-creation round trip preserves the
|
|
591
|
+
* `isInternationalCheckout=true` flag as well as `zonosTestMode` /
|
|
592
|
+
* `zonosQaUrl`.
|
|
593
|
+
*
|
|
594
|
+
* Safe to call more than once — idempotent thanks to the `data-zonos-…`
|
|
595
|
+
* attribute on rewritten anchors.
|
|
596
|
+
*/
|
|
597
|
+
const fixBigCommerceLoginCreateAccountLink = () => {
|
|
598
|
+
if (!window.Zonos.isBigCommerce) {
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
if (!window.location.pathname.includes('/login.php')) {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
604
|
+
rewriteCreateAccountLinks();
|
|
605
|
+
// BC's login page often renders the auth form asynchronously, so the
|
|
606
|
+
// anchor may not exist yet when this runs. Observe for a short window,
|
|
607
|
+
// then stop so we don't leak a listener for the rest of the session.
|
|
608
|
+
const observer = new MutationObserver(() => {
|
|
609
|
+
rewriteCreateAccountLinks();
|
|
610
|
+
});
|
|
611
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
612
|
+
// 10 seconds is plenty for the login form to mount; stopping the observer
|
|
613
|
+
// avoids churn from the rest of the page's normal DOM activity.
|
|
614
|
+
setTimeout(() => observer.disconnect(), 10000);
|
|
615
|
+
};
|
|
616
|
+
|
|
293
617
|
const isDisabledCountry = (showLog = true) => {
|
|
294
618
|
if (!localization.localizationStore.localizationLoaded) {
|
|
295
619
|
return true;
|
|
@@ -339,19 +663,27 @@ const FALLBACK_SHIP_TO_COUNTRY_SELECTOR = 'select[name="shippingAddress.countryC
|
|
|
339
663
|
*/
|
|
340
664
|
const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelected, onLoggedInInternationalAddressDetected, }) => {
|
|
341
665
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
666
|
+
// Fetch the Storefront API data once up front and thread it through every
|
|
667
|
+
// decision below (bypass, shipping-address inspection, force-login). The
|
|
668
|
+
// function always needs the checkout for the address check, so reusing one
|
|
669
|
+
// fetch avoids the earlier 4x round-trip fan-out where bypass, address
|
|
670
|
+
// lookup, and force-login each fetched independently.
|
|
671
|
+
const checkoutId = await fetchCheckoutId();
|
|
672
|
+
if (!checkoutId) {
|
|
673
|
+
return 'noAction';
|
|
674
|
+
}
|
|
675
|
+
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
676
|
+
const preFetched = { checkout, checkoutId };
|
|
342
677
|
// Check if the customer belongs to a bypass group (e.g. resellers) before
|
|
343
678
|
// redirecting them away from BigCommerce native checkout. This delegates to
|
|
344
679
|
// the shared helper so the bypass decision has a single source of truth and
|
|
345
680
|
// reuses the cached promise warmed by `initBigCommerceBypassCheck`.
|
|
346
|
-
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup(
|
|
681
|
+
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup({
|
|
682
|
+
preFetched,
|
|
683
|
+
});
|
|
347
684
|
if (shouldBypass) {
|
|
348
685
|
return 'noAction';
|
|
349
686
|
}
|
|
350
|
-
const checkoutId = await fetchCheckoutId();
|
|
351
|
-
if (!checkoutId) {
|
|
352
|
-
return 'noAction';
|
|
353
|
-
}
|
|
354
|
-
const checkout = await fetchBigCommerceCheckout(checkoutId);
|
|
355
687
|
const shippingAddress = (_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.consignments) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.shippingAddress;
|
|
356
688
|
if (!(shippingAddress === null || shippingAddress === void 0 ? void 0 : shippingAddress.countryCode)) {
|
|
357
689
|
return 'noAction';
|
|
@@ -374,6 +706,14 @@ const checkLoggedInUserShippingAddress = async ({ onInternationalCheckoutSelecte
|
|
|
374
706
|
return 'optedOut';
|
|
375
707
|
}
|
|
376
708
|
}
|
|
709
|
+
// Force-login merchants must sign the guest shopper in before we leave
|
|
710
|
+
// BC's native checkout. Reuse the checkout we already fetched above so we
|
|
711
|
+
// don't double up on Storefront API round trips.
|
|
712
|
+
const forceLogin = await checkBigCommerceForceLogin({ preFetched });
|
|
713
|
+
if (forceLogin.shouldForceLogin && forceLogin.redirectUrl) {
|
|
714
|
+
window.location.href = forceLogin.redirectUrl;
|
|
715
|
+
return 'redirected';
|
|
716
|
+
}
|
|
377
717
|
if (onInternationalCheckoutSelected) {
|
|
378
718
|
await onInternationalCheckoutSelected();
|
|
379
719
|
}
|
|
@@ -431,9 +771,17 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
|
|
|
431
771
|
// Only check bypass after confirming the country is shippable (i.e. user is
|
|
432
772
|
// about to be redirected to Zonos international checkout). Force-refresh so
|
|
433
773
|
// we re-fetch BigCommerce checkout data every time the ship-to country
|
|
434
|
-
// changes — prevents stale customer-group data from a cached fetch.
|
|
774
|
+
// changes — prevents stale customer-group data from a cached fetch. Share
|
|
775
|
+
// one fetch between the bypass and force-login decisions so this poll
|
|
776
|
+
// tick does 2 Storefront API round trips instead of 4.
|
|
777
|
+
const checkoutId = await fetchCheckoutId();
|
|
778
|
+
const checkout = checkoutId
|
|
779
|
+
? await fetchBigCommerceCheckout(checkoutId)
|
|
780
|
+
: null;
|
|
781
|
+
const preFetched = { checkout, checkoutId };
|
|
435
782
|
const { shouldBypass } = await checkBigCommerceBypassCustomerGroup({
|
|
436
783
|
forceRefresh: true,
|
|
784
|
+
preFetched,
|
|
437
785
|
});
|
|
438
786
|
if (shouldBypass) {
|
|
439
787
|
// Logged-in customer is in a bypass group — keep them on BC native
|
|
@@ -441,6 +789,14 @@ const watchImmediateBigcommerceDomesticCheckoutRedirect = ({ domesticRedirectedB
|
|
|
441
789
|
VarianceTest.log('Bypass customer group detected on BC checkout, stopping interval', 'info');
|
|
442
790
|
return true;
|
|
443
791
|
}
|
|
792
|
+
// Same force-login gate as the logged-in-default-address path — we run
|
|
793
|
+
// it *after* the bypass check so reseller groups never see the login
|
|
794
|
+
// bounce, and *before* any UI/session state flips to the redirect.
|
|
795
|
+
const forceLogin = await checkBigCommerceForceLogin({ preFetched });
|
|
796
|
+
if (forceLogin.shouldForceLogin && forceLogin.redirectUrl) {
|
|
797
|
+
window.location.href = forceLogin.redirectUrl;
|
|
798
|
+
return true;
|
|
799
|
+
}
|
|
444
800
|
if (onInternationalCheckoutSelected) {
|
|
445
801
|
await onInternationalCheckoutSelected();
|
|
446
802
|
}
|
|
@@ -1564,6 +1920,15 @@ const ZonosCheckout = class {
|
|
|
1564
1920
|
window.location.href = buildBigcommerceRedirectUrl('/checkout');
|
|
1565
1921
|
return;
|
|
1566
1922
|
}
|
|
1923
|
+
// Merchants who disable BC guest checkout need the shopper
|
|
1924
|
+
// signed in before we open the Zonos international checkout.
|
|
1925
|
+
// Redirecting here keeps the dialog from flashing before the
|
|
1926
|
+
// login bounce.
|
|
1927
|
+
const forceLogin = await checkBigCommerceForceLogin();
|
|
1928
|
+
if (forceLogin.shouldForceLogin && forceLogin.redirectUrl) {
|
|
1929
|
+
window.location.href = forceLogin.redirectUrl;
|
|
1930
|
+
return;
|
|
1931
|
+
}
|
|
1567
1932
|
}
|
|
1568
1933
|
// start loading
|
|
1569
1934
|
cart.stripeStore.isFetchingSession = true;
|
|
@@ -1816,6 +2181,19 @@ const ZonosCheckout = class {
|
|
|
1816
2181
|
// Start fetching BigCommerce customer group on page load so the bypass
|
|
1817
2182
|
// result is ready by the time checkout opens or the BC watcher fires
|
|
1818
2183
|
initBigCommerceBypassCheck();
|
|
2184
|
+
// Warm the BigCommerce `/checkouts/settings` fetch (merchant's
|
|
2185
|
+
// `guest_checkout_type`) so force-login gating resolves instantly when
|
|
2186
|
+
// the shopper clicks checkout — otherwise the first checkout open
|
|
2187
|
+
// would block on a proxy round trip.
|
|
2188
|
+
initBigCommerceForceLoginCheck();
|
|
2189
|
+
// On BC's `/login.php`, rewrite the "Create account" button href so
|
|
2190
|
+
// the post-signup round trip preserves the `from=cart.php?...` flag
|
|
2191
|
+
// that carries the shopper back into Zonos international checkout.
|
|
2192
|
+
fixBigCommerceLoginCreateAccountLink();
|
|
2193
|
+
// If BC redirected the shopper back here after login with the Zonos
|
|
2194
|
+
// resume flag, auto-open the international checkout. Strip the flag
|
|
2195
|
+
// from the URL so a refresh doesn't keep re-triggering the dialog.
|
|
2196
|
+
this.handleBigcommerceInternationalResumeFlag();
|
|
1819
2197
|
// check if bigcommerce, if user enters the shipping address that's in the shipping zone at bigcommerce checkout
|
|
1820
2198
|
watchImmediateBigcommerceDomesticCheckoutRedirect({
|
|
1821
2199
|
domesticRedirectedBtnSelector: CheckoutConfig.domesticRedirectedBtnSelector,
|
|
@@ -1897,6 +2275,53 @@ const ZonosCheckout = class {
|
|
|
1897
2275
|
clearInterval(interval);
|
|
1898
2276
|
}, 10000);
|
|
1899
2277
|
}
|
|
2278
|
+
/**
|
|
2279
|
+
* After BigCommerce's `/login.php` round trip, the shopper lands back on
|
|
2280
|
+
* `cart.php?isInternationalCheckout=true`. Detect the flag, strip it from
|
|
2281
|
+
* the URL (so refreshing doesn't re-open the dialog), then fire the
|
|
2282
|
+
* international-checkout trigger once three preconditions are all met:
|
|
2283
|
+
* 1. Hello localization finished loading (`localizationLoaded`).
|
|
2284
|
+
* 2. A country code is selected — otherwise `buildCartDetail` runs
|
|
2285
|
+
* without a `countryCode` / `currencyCode` and never builds a cart.
|
|
2286
|
+
* 3. The hidden trigger button has mounted.
|
|
2287
|
+
*
|
|
2288
|
+
* Without the first two gates we race Hello's own init and the click
|
|
2289
|
+
* fires against a half-initialized store, which is what happens when
|
|
2290
|
+
* the shopper refreshes back into cart.php straight from the login
|
|
2291
|
+
* round trip.
|
|
2292
|
+
*/
|
|
2293
|
+
handleBigcommerceInternationalResumeFlag() {
|
|
2294
|
+
if (!window.Zonos.isBigCommerce) {
|
|
2295
|
+
return;
|
|
2296
|
+
}
|
|
2297
|
+
const url = new URL(window.location.href);
|
|
2298
|
+
if (url.searchParams.get(BIGCOMMERCE_INTERNATIONAL_CHECKOUT_FLAG) !== 'true') {
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
2301
|
+
url.searchParams.delete(BIGCOMMERCE_INTERNATIONAL_CHECKOUT_FLAG);
|
|
2302
|
+
window.history.replaceState({}, '', url.toString());
|
|
2303
|
+
const start = Date.now();
|
|
2304
|
+
const interval = setInterval(() => {
|
|
2305
|
+
if (!localization.localizationStore.localizationLoaded ||
|
|
2306
|
+
!localization.localizationStore.selectedCountryCode) {
|
|
2307
|
+
if (Date.now() - start > 15000) {
|
|
2308
|
+
clearInterval(interval);
|
|
2309
|
+
VarianceTest.log('BigCommerce international checkout resume flag: localization did not initialize within 15s', 'info');
|
|
2310
|
+
}
|
|
2311
|
+
return;
|
|
2312
|
+
}
|
|
2313
|
+
const btn = document.querySelector(`#${CheckoutConfig.checkoutHiddenInternationalBtnSelector}`);
|
|
2314
|
+
if (btn) {
|
|
2315
|
+
clearInterval(interval);
|
|
2316
|
+
btn.dispatchEvent(createCustomEvent.createCustomEvent('click'));
|
|
2317
|
+
return;
|
|
2318
|
+
}
|
|
2319
|
+
if (Date.now() - start > 15000) {
|
|
2320
|
+
clearInterval(interval);
|
|
2321
|
+
VarianceTest.log('BigCommerce international checkout resume flag: trigger button did not mount within 15s', 'info');
|
|
2322
|
+
}
|
|
2323
|
+
}, 200);
|
|
2324
|
+
}
|
|
1900
2325
|
/**
|
|
1901
2326
|
* For storybook to set to finish step, this is to trigger in the story for zonos-checkout-finish
|
|
1902
2327
|
*/
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const cart = require('./cart-
|
|
6
|
+
const cart = require('./cart-d08c87e2.js');
|
|
7
7
|
const cleanHtmlMarkdown = require('./cleanHtmlMarkdown-31da84b7.js');
|
|
8
8
|
const zonosStore = require('./zonosStore-1c517e55.js');
|
|
9
9
|
const classes = require('./classes-b7918f56.js');
|
|
10
10
|
const styles = require('./styles-d1e64fb9.js');
|
|
11
|
-
require('./localization-
|
|
11
|
+
require('./localization-a7fac4b4.js');
|
|
12
12
|
require('./handleFetch-954f30e1.js');
|
|
13
13
|
require('./VarianceTest-bec00ea8.js');
|
|
14
14
|
require('./isDarkColor-bfe6d1eb.js');
|
|
@@ -3,20 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const paypal = require('./paypal-
|
|
8
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-d08c87e2.js');
|
|
7
|
+
const paypal = require('./paypal-73a542cb.js');
|
|
8
|
+
const localization = require('./localization-a7fac4b4.js');
|
|
9
9
|
const zonosStore = require('./zonosStore-1c517e55.js');
|
|
10
10
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
11
11
|
const createCustomEvent = require('./createCustomEvent-7b6fad95.js');
|
|
12
12
|
const getBorderRadius = require('./getBorderRadius-db55a464.js');
|
|
13
13
|
const VarianceTest = require('./VarianceTest-bec00ea8.js');
|
|
14
14
|
const submitGtag = require('./submitGtag-9ac5a42e.js');
|
|
15
|
-
const isCollectMobileTablet = require('./isCollectMobileTablet-
|
|
15
|
+
const isCollectMobileTablet = require('./isCollectMobileTablet-9675485f.js');
|
|
16
16
|
const classes = require('./classes-b7918f56.js');
|
|
17
17
|
const ILanguage = require('./ILanguage-98b04442.js');
|
|
18
|
-
const renderCheckoutCurrency = require('./renderCheckoutCurrency-
|
|
19
|
-
const placeTestOrder = require('./placeTestOrder-
|
|
18
|
+
const renderCheckoutCurrency = require('./renderCheckoutCurrency-a374741a.js');
|
|
19
|
+
const placeTestOrder = require('./placeTestOrder-aefd31e8.js');
|
|
20
20
|
const renderFallback = require('./renderFallback-bc20ee20.js');
|
|
21
21
|
require('./isDarkColor-bfe6d1eb.js');
|
|
22
22
|
require('./isContrastColor-6a17f408.js');
|
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const isCollectMobileTablet = require('./isCollectMobileTablet-
|
|
8
|
-
const paypal = require('./paypal-
|
|
9
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-d08c87e2.js');
|
|
7
|
+
const isCollectMobileTablet = require('./isCollectMobileTablet-9675485f.js');
|
|
8
|
+
const paypal = require('./paypal-73a542cb.js');
|
|
9
|
+
const localization = require('./localization-a7fac4b4.js');
|
|
10
10
|
const zonosStore = require('./zonosStore-1c517e55.js');
|
|
11
11
|
const buildCartItemsByTempCart = require('./buildCartItemsByTempCart-edddbf4b.js');
|
|
12
12
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const cart = require('./cart-
|
|
7
|
-
const localization = require('./localization-
|
|
6
|
+
const cart = require('./cart-d08c87e2.js');
|
|
7
|
+
const localization = require('./localization-a7fac4b4.js');
|
|
8
8
|
const zonosStore = require('./zonosStore-1c517e55.js');
|
|
9
9
|
const getGenericSettingsOverride = require('./getGenericSettingsOverride-c0ca32b9.js');
|
|
10
10
|
const handleFetch = require('./handleFetch-954f30e1.js');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const localization = require('./localization-
|
|
6
|
+
const localization = require('./localization-a7fac4b4.js');
|
|
7
7
|
const zonosStore = require('./zonosStore-1c517e55.js');
|
|
8
8
|
const classes = require('./classes-b7918f56.js');
|
|
9
9
|
require('./handleFetch-954f30e1.js');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-b1f95d96.js');
|
|
6
|
-
const localization = require('./localization-
|
|
6
|
+
const localization = require('./localization-a7fac4b4.js');
|
|
7
7
|
const zonosStore = require('./zonosStore-1c517e55.js');
|
|
8
8
|
const formatStringWithLinks = require('./formatStringWithLinks-52341fc7.js');
|
|
9
9
|
const isDarkColor = require('./isDarkColor-bfe6d1eb.js');
|