@zonos/elements 1.3.51 → 1.3.52
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/CheckoutConfig-65376e00.js +40 -0
- package/dist/cjs/{cart-546d1602.js → cart-61a8983d.js} +238 -375
- package/dist/cjs/{createCustomEvent-9b91480b.js → createCustomEvent-228027b5.js} +3 -2
- package/dist/cjs/handleFetch-842c95b0.js +322 -0
- package/dist/cjs/index.cjs.js +75 -35
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{paypal-83f49f9a.js → paypal-f1eb6621.js} +16 -16
- package/dist/cjs/zonos-address_8.cjs.entry.js +4 -4
- package/dist/cjs/{zonos-cart-items_12.cjs.entry.js → zonos-badge_13.cjs.entry.js} +41 -9
- package/dist/cjs/zonos-checkout.cjs.entry.js +75 -174
- package/dist/cjs/zonos-controller.cjs.entry.js +27 -25
- package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +2 -2
- package/dist/cjs/zonos-elements.cjs.js +1 -1
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +2 -2
- package/dist/cjs/zonos-hello.cjs.entry.js +11 -11
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-notification_3.cjs.entry.js +9 -9
- package/dist/cjs/zonos-tooltip.cjs.entry.js +27 -0
- package/dist/collection/components/checkout/zonos-checkout/zonos-cart-subtotal/zonos-cart-subtotal.js +5 -2
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +44 -20
- package/dist/collection/components/store/checkout/cart.js +14 -2
- package/dist/collection/components/store/checkout/stripe.js +9 -4
- package/dist/collection/components/store/translationStore/strings.arabic.js +3 -3
- package/dist/collection/components/store/translationStore/strings.base.js +3 -3
- package/dist/collection/components/store/translationStore/strings.chinese.js +3 -3
- package/dist/collection/components/store/translationStore/strings.danish.js +3 -3
- package/dist/collection/components/store/translationStore/strings.dutch.js +3 -3
- package/dist/collection/components/store/translationStore/strings.french.js +3 -3
- package/dist/collection/components/store/translationStore/strings.german.js +3 -3
- package/dist/collection/components/store/translationStore/strings.hebrew.js +3 -3
- package/dist/collection/components/store/translationStore/strings.indonesian.js +3 -3
- package/dist/collection/components/store/translationStore/strings.italian.js +3 -3
- package/dist/collection/components/store/translationStore/strings.japanese.js +3 -3
- package/dist/collection/components/store/translationStore/strings.korean.js +3 -3
- package/dist/collection/components/store/translationStore/strings.norwegian.js +3 -3
- package/dist/collection/components/store/translationStore/strings.polish.js +3 -3
- package/dist/collection/components/store/translationStore/strings.portuguese.js +3 -3
- package/dist/collection/components/store/translationStore/strings.russian.js +3 -3
- package/dist/collection/components/store/translationStore/strings.spanish.js +3 -3
- package/dist/collection/components/store/translationStore/strings.swedish.js +3 -3
- package/dist/collection/components/store/translationStore/strings.turkish.js +3 -3
- package/dist/collection/components/store/translationStore/strings.vietnamese.js +3 -3
- package/dist/collection/components/utils/api/buildCartItemsByTempCart.js +14 -14
- package/dist/collection/components/utils/api/calculateLandedCostNormalized.js +28 -0
- package/dist/collection/components/utils/api/cartCalculateLandedCost.js +19 -0
- package/dist/collection/components/utils/api/prepCalculateLandedCost.js +65 -0
- package/dist/collection/components/utils/checkout/initCheckout.js +4 -2
- package/dist/collection/environment.js +1 -1
- package/dist/collection/scripts/_getNextFallbackUrl.js +1 -0
- package/dist/collection/scripts/_getTempCartById.js +14 -0
- package/dist/collection/scripts/_zonosBase.js +39 -10
- package/dist/collection/scripts/cart/_getCartIdFromParam.js +9 -0
- package/dist/collection/scripts/cart/_setupCartData.js +18 -0
- package/dist/collection/types/checkout/CheckoutConfig.js +2 -1
- package/dist/collection/types/generated/graphql.customer.types.js +12 -0
- package/dist/collection/utils/formattedCloudflareApiUrl.js +8 -2
- package/dist/collection/utils/generateCloudflareDeployUrl.js +3 -0
- package/dist/esm/CheckoutConfig-57350b28.js +36 -0
- package/dist/esm/{cart-51529af2.js → cart-45d2861f.js} +193 -327
- package/dist/esm/{createCustomEvent-b8bbdf5e.js → createCustomEvent-3fcc948a.js} +2 -1
- package/dist/esm/handleFetch-37cea185.js +315 -0
- package/dist/esm/index.js +56 -17
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{paypal-905325d0.js → paypal-ee310945.js} +2 -2
- package/dist/esm/zonos-address_8.entry.js +2 -2
- package/dist/esm/{zonos-cart-items_12.entry.js → zonos-badge_13.entry.js} +40 -9
- package/dist/esm/zonos-checkout.entry.js +61 -160
- package/dist/esm/zonos-controller.entry.js +6 -4
- package/dist/esm/zonos-country-flag.entry.js +2 -2
- package/dist/esm/zonos-country-select_4.entry.js +2 -2
- package/dist/esm/zonos-elements.js +1 -1
- package/dist/esm/zonos-hello-dialog.entry.js +2 -2
- package/dist/esm/zonos-hello.entry.js +2 -2
- package/dist/esm/zonos-language-select_2.entry.js +2 -2
- package/dist/esm/zonos-notification_3.entry.js +3 -3
- package/dist/esm/zonos-tooltip.entry.js +23 -0
- package/dist/esm-es5/CheckoutConfig-57350b28.js +1 -0
- package/dist/esm-es5/cart-45d2861f.js +1 -0
- package/dist/esm-es5/{createCustomEvent-b8bbdf5e.js → createCustomEvent-3fcc948a.js} +1 -1
- package/dist/esm-es5/handleFetch-37cea185.js +1 -0
- package/dist/esm-es5/index.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/{paypal-905325d0.js → paypal-ee310945.js} +1 -1
- package/dist/esm-es5/zonos-address_8.entry.js +1 -1
- package/dist/esm-es5/zonos-badge_13.entry.js +1 -0
- package/dist/esm-es5/zonos-checkout.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +1 -1
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-elements.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-notification_3.entry.js +1 -1
- package/dist/esm-es5/zonos-tooltip.entry.js +1 -0
- package/dist/scripts/index.d.ts +74 -87
- 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 +0 -2
- package/dist/types/components/store/checkout/cart.d.ts +13 -3
- package/dist/types/components/store/checkout/stripe.d.ts +3 -1
- package/dist/types/components/store/translationStore/strings.arabic.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.base.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.chinese.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.danish.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.dutch.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.french.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.german.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.hebrew.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.indonesian.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.italian.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.japanese.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.korean.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.norwegian.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.polish.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.portuguese.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.russian.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.spanish.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.swedish.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.turkish.d.ts +3 -3
- package/dist/types/components/store/translationStore/strings.vietnamese.d.ts +3 -3
- package/dist/types/components/store/translationStore.d.ts +1 -1
- package/dist/types/components/utils/api/buildCartItemsByTempCart.d.ts +8 -3
- package/dist/types/components/utils/api/calculateLandedCostNormalized.d.ts +2 -0
- package/dist/types/components/utils/api/cartCalculateLandedCost.d.ts +5 -0
- package/dist/types/components/utils/api/prepCalculateLandedCost.d.ts +5 -1
- package/dist/types/components/utils/checkout/getIsTestMode.d.ts +1 -1
- package/dist/types/scripts/_getNextFallbackUrl.d.ts +1 -0
- package/dist/types/scripts/_getTempCartById.d.ts +8 -0
- package/dist/types/scripts/_zonosBase.d.ts +15 -12
- package/dist/types/scripts/cart/_getCartIdFromParam.d.ts +4 -0
- package/dist/types/scripts/cart/_setupCartData.d.ts +7 -0
- package/dist/types/types/checkout/CheckoutConfig.d.ts +18 -3
- package/dist/types/types/checkout/api/CalculateLandedCostRequest.d.ts +42 -1
- package/dist/types/types/checkout/api/NormalizedTempCart.d.ts +37 -0
- package/dist/types/types/generated/graphql.customer.types.d.ts +249 -2
- package/dist/types/types/generated/graphql.customer.types.ts +251 -3
- package/dist/types/utils/formattedCloudflareApiUrl.d.ts +2 -2
- package/dist/zonos-elements/assets/RemoveIcon.svg +1 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/p-042c466d.system.entry.js +1 -0
- package/dist/zonos-elements/p-10cb0064.entry.js +1 -0
- package/dist/zonos-elements/{p-5e56828a.entry.js → p-259ccf8d.entry.js} +1 -1
- package/dist/zonos-elements/p-2a47d2cc.system.entry.js +1 -0
- package/dist/zonos-elements/{p-ffd76226.entry.js → p-31eb835c.entry.js} +1 -1
- package/dist/zonos-elements/{p-58d9803d.entry.js → p-36360905.entry.js} +1 -1
- package/dist/zonos-elements/{p-1828a4ff.system.entry.js → p-3703b814.system.entry.js} +1 -1
- package/dist/zonos-elements/p-4146feec.js +1 -0
- package/dist/zonos-elements/p-446c8f02.system.entry.js +1 -0
- package/dist/zonos-elements/{p-2c323311.system.js → p-5590f90c.system.js} +1 -1
- package/dist/zonos-elements/p-588396df.js +1 -0
- package/dist/zonos-elements/{p-aa5d669b.js → p-6e59c6e4.js} +2 -2
- package/dist/zonos-elements/p-6eedc3f8.entry.js +1 -0
- package/dist/zonos-elements/p-747eed39.entry.js +1 -0
- package/dist/zonos-elements/{p-00100b17.system.entry.js → p-8228e87c.system.entry.js} +1 -1
- package/dist/zonos-elements/p-827868e6.entry.js +1 -0
- package/dist/zonos-elements/{p-cc7a4fca.entry.js → p-88005b94.entry.js} +1 -1
- package/dist/zonos-elements/p-895fdefb.js +1 -0
- package/dist/zonos-elements/p-8f7773b0.system.js +1 -0
- package/dist/zonos-elements/{p-9a0401fd.entry.js → p-8fa49d94.entry.js} +1 -1
- package/dist/zonos-elements/p-a74a7afa.system.js +1 -0
- package/dist/zonos-elements/p-b1861e64.system.js +1 -0
- package/dist/zonos-elements/{p-8473f99a.system.entry.js → p-b842b96a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-9e976332.entry.js → p-bb186075.entry.js} +1 -1
- package/dist/zonos-elements/{p-b1a8b874.system.entry.js → p-c008648a.system.entry.js} +1 -1
- package/dist/zonos-elements/p-c78dd680.system.js +1 -1
- package/dist/zonos-elements/{p-6b42fa1b.system.entry.js → p-cd4ad1be.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-59e85369.system.entry.js → p-d62e6bb0.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-496e040f.system.entry.js → p-dc12f30a.system.entry.js} +1 -1
- package/dist/zonos-elements/p-eb2aedd0.js +1 -0
- package/dist/zonos-elements/{p-c89859cf.system.js → p-f124e459.system.js} +2 -2
- package/dist/zonos-elements/p-f527cd5b.entry.js +1 -0
- package/dist/zonos-elements/p-f826b979.system.entry.js +1 -0
- package/dist/zonos-elements/p-f87a635b.system.js +1 -0
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +1 -1
- package/dist/cjs/logError-4e2f2020.js +0 -58
- package/dist/cjs/zonos-badge_2.cjs.entry.js +0 -57
- package/dist/collection/components/utils/api/tempCartItem/getAttributes.js +0 -66
- package/dist/collection/components/utils/api/tempCartItem/getMeasurements.js +0 -58
- package/dist/esm/logError-c456c092.js +0 -55
- package/dist/esm/zonos-badge_2.entry.js +0 -52
- package/dist/esm-es5/cart-51529af2.js +0 -1
- package/dist/esm-es5/logError-c456c092.js +0 -1
- package/dist/esm-es5/zonos-badge_2.entry.js +0 -1
- package/dist/esm-es5/zonos-cart-items_12.entry.js +0 -1
- package/dist/types/components/utils/api/tempCartItem/getAttributes.d.ts +0 -11
- package/dist/types/components/utils/api/tempCartItem/getMeasurements.d.ts +0 -7
- package/dist/types/types/checkout/api/TempCart.d.ts +0 -80
- package/dist/zonos-elements/p-101c41bf.entry.js +0 -1
- package/dist/zonos-elements/p-3c4eec63.system.entry.js +0 -1
- package/dist/zonos-elements/p-47945026.system.entry.js +0 -1
- package/dist/zonos-elements/p-47c72c50.system.entry.js +0 -1
- package/dist/zonos-elements/p-4e77ed65.system.entry.js +0 -1
- package/dist/zonos-elements/p-6013e370.entry.js +0 -1
- package/dist/zonos-elements/p-63db40b9.system.js +0 -1
- package/dist/zonos-elements/p-8b8ef484.entry.js +0 -1
- package/dist/zonos-elements/p-b57d24f2.entry.js +0 -1
- package/dist/zonos-elements/p-ba0289f9.entry.js +0 -1
- package/dist/zonos-elements/p-c8a3303b.js +0 -1
- package/dist/zonos-elements/p-d413cd13.js +0 -1
- package/dist/zonos-elements/p-e758ec31.system.js +0 -1
- package/dist/zonos-elements/p-eaa335e1.js +0 -1
- package/dist/zonos-elements/p-fcfde531.system.js +0 -1
- /package/dist/collection/types/checkout/api/{TempCart.js → NormalizedTempCart.js} +0 -0
|
@@ -2,9 +2,12 @@ var _a;
|
|
|
2
2
|
import { log } from "../components/utils/logging/log";
|
|
3
3
|
import { logError } from "../components/utils/logging/logError";
|
|
4
4
|
import { checkIfLoadVersionDomain } from "./_checkIfLoadVersionDomain";
|
|
5
|
-
import { getNextFallbackUrl, } from "./_getNextFallbackUrl";
|
|
5
|
+
import { getNextFallbackUrl, MAIN_LOAD_CDN_TYPE, } from "./_getNextFallbackUrl";
|
|
6
6
|
import { getZonosQaUrl } from "./_getZonosQaUrl";
|
|
7
7
|
import { zonosLoadStripe } from "./_loadStripe";
|
|
8
|
+
import { getCartIdFromQueryParam } from "./cart/_getCartIdFromParam";
|
|
9
|
+
import { setupCartData } from "./cart/_setupCartData";
|
|
10
|
+
import { checkoutHiddenBtnSelector, } from "../types/checkout/CheckoutConfig";
|
|
8
11
|
/**
|
|
9
12
|
* 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
|
|
10
13
|
*/
|
|
@@ -25,7 +28,6 @@ const ZONOS_URL = process.env.NEXT_PUBLIC_ZONOS_CDN_URL;
|
|
|
25
28
|
const JS_DELIVR_ZONOS_URL = zonosLoadUrl || process.env.NEXT_PUBLIC_ZONOS_JS_DELIVR_CDN_URL;
|
|
26
29
|
const UNPKG_ZONOS_URL = process.env.NEXT_PUBLIC_ZONOS_UNPKG_CDN_URL;
|
|
27
30
|
const CDNJS_ZONOS_URL = process.env.NEXT_PUBLIC_ZONOS_CDNJS_CDN_URL;
|
|
28
|
-
export const MAIN_LOAD_CDN_TYPE = 'jsdelivr';
|
|
29
31
|
const INTER_FONT_URL = 'https://rsms.me';
|
|
30
32
|
const GOOGLE_FONT_URL = 'https://fonts.googleapis.com';
|
|
31
33
|
const INTER_FONT_REGEX = /^https:\/\/rsms\.me\/inter\/inter\.css(.*)$/;
|
|
@@ -41,6 +43,7 @@ Zonos.zonosConversionTest = typeof window !== 'undefined' &&
|
|
|
41
43
|
Zonos._paypalMockResponse = null;
|
|
42
44
|
Zonos.isBigCommerce = false;
|
|
43
45
|
Zonos.releaseDate = process.env.NEXT_PUBLIC_RELEASE_DATE;
|
|
46
|
+
Zonos.isLegacyCheckout = false;
|
|
44
47
|
/**
|
|
45
48
|
* By default, the package will load from npm
|
|
46
49
|
*/
|
|
@@ -48,22 +51,49 @@ Zonos.isNpm = true;
|
|
|
48
51
|
Zonos.zonosQaUrl = null;
|
|
49
52
|
Zonos.version = `v${process.env.NEXT_PUBLIC_ZONOS_PACKAGE_VERSION}`;
|
|
50
53
|
Zonos.modeAlerted = false;
|
|
51
|
-
Zonos.
|
|
54
|
+
Zonos.cartData = null;
|
|
52
55
|
Zonos.paypal = null;
|
|
53
56
|
Zonos.getCurrentTimestamp = () => new Date().getTime();
|
|
54
57
|
Zonos.zonosController = null;
|
|
55
58
|
Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSettings, onCountryChange, overrideCurrencyFormat, storeId, zonosApiKey, }) => {
|
|
59
|
+
_a.cartId = getCartIdFromQueryParam();
|
|
56
60
|
if (_a.doneInit) {
|
|
57
61
|
// do nothing if zonos is already initializeds
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
60
64
|
log(`====== ZONOS DEBUG MODE: on (${_a.version}) ======`);
|
|
61
|
-
if (!zonosApiKey) {
|
|
62
|
-
logError('Missing Zonos API key');
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
65
|
_a.zonosApiKey = zonosApiKey;
|
|
66
66
|
_a.storeId = storeId;
|
|
67
|
+
if (_a.isNpm) {
|
|
68
|
+
log('====== ZONOS LOADING FROM NPM ======');
|
|
69
|
+
// zonosApiKey is required if tempCartUUID in query params are not provided
|
|
70
|
+
if (!zonosApiKey && !_a.cartId) {
|
|
71
|
+
logError('Zonos API key is required unless `tempCartUUID` is provided in url query params.');
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* This is mainly for user that integrates Zonos with npm
|
|
76
|
+
* If cartUUID is provided in query param and cartData is not available, get and initialize cart data to prepare to open checkout right away
|
|
77
|
+
*/
|
|
78
|
+
if (!_a.cartData && _a.cartId) {
|
|
79
|
+
log('Initialize cart data');
|
|
80
|
+
const params = await setupCartData(_a.cartId);
|
|
81
|
+
if (!params) {
|
|
82
|
+
logError('Failed to get cart data');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
_a.cartData = params.cartData;
|
|
86
|
+
_a.zonosApiKey = params.zonosApiKey;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// inject hidden button to body to trigger checkout right away if we have cartData
|
|
90
|
+
if (_a.cartId && _a.cartData) {
|
|
91
|
+
log('Cart data is available, inject hidden button and trigger checkout');
|
|
92
|
+
const hiddenButton = document.createElement('button');
|
|
93
|
+
hiddenButton.style.display = 'none';
|
|
94
|
+
hiddenButton.id = `${checkoutHiddenBtnSelector}`;
|
|
95
|
+
document.body.appendChild(hiddenButton);
|
|
96
|
+
}
|
|
67
97
|
log('init zonos');
|
|
68
98
|
// inject zonos cdn
|
|
69
99
|
_a.injectZonosCdn();
|
|
@@ -81,7 +111,6 @@ Zonos.init = async ({ appearance, checkoutSettings, currencyConverter, helloSett
|
|
|
81
111
|
onCountryChange,
|
|
82
112
|
overrideCurrencyFormat,
|
|
83
113
|
},
|
|
84
|
-
zonosApiKey,
|
|
85
114
|
});
|
|
86
115
|
_a.doneInit = true;
|
|
87
116
|
};
|
|
@@ -153,7 +182,7 @@ Zonos.disablePlaceOrderButtons = ({ autoEnable = true, config, disable, placeOrd
|
|
|
153
182
|
}
|
|
154
183
|
}
|
|
155
184
|
};
|
|
156
|
-
Zonos.injectController = ({ config,
|
|
185
|
+
Zonos.injectController = ({ config, }) => {
|
|
157
186
|
var _b;
|
|
158
187
|
if (document.querySelector('zonos-controller')) {
|
|
159
188
|
return;
|
|
@@ -181,7 +210,7 @@ Zonos.injectController = ({ config, zonosApiKey, }) => {
|
|
|
181
210
|
}
|
|
182
211
|
const zonosController = document.createElement('zonos-controller');
|
|
183
212
|
zonosController.config = config;
|
|
184
|
-
zonosController.zonosApiKey = zonosApiKey;
|
|
213
|
+
zonosController.zonosApiKey = _a.zonosApiKey || '';
|
|
185
214
|
zonosController.addEventListener('stripeInitEvent', async (event) => {
|
|
186
215
|
const { detail } = event;
|
|
187
216
|
log('loading Stripe');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const TEMP_CART_ID_QUERY_PARAM = 'tempCartUUID';
|
|
2
|
+
/**
|
|
3
|
+
* Simple function to get the cart id from the query param.
|
|
4
|
+
*/
|
|
5
|
+
export const getCartIdFromQueryParam = () => {
|
|
6
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
7
|
+
const cartId = urlParams.get(TEMP_CART_ID_QUERY_PARAM);
|
|
8
|
+
return cartId;
|
|
9
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { log } from "../../components/utils/logging/log";
|
|
2
|
+
import { logError } from "../../components/utils/logging/logError";
|
|
3
|
+
import { getTempCartById } from "../_getTempCartBy";
|
|
4
|
+
export const setupCartData = async (cartId) => {
|
|
5
|
+
const tempCartResult = await getTempCartById(cartId);
|
|
6
|
+
log('[ZONOS - loadZonos] getting temp cart data', 'info', tempCartResult);
|
|
7
|
+
if (!tempCartResult) {
|
|
8
|
+
logError('[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.');
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
cartData: tempCartResult.cartData,
|
|
13
|
+
storeFavicon: tempCartResult.storeFaviconUrl,
|
|
14
|
+
storeId: tempCartResult.cartData.storeId,
|
|
15
|
+
storeLogo: tempCartResult.storeLogoUrl,
|
|
16
|
+
zonosApiKey: tempCartResult.cartData.credentialToken,
|
|
17
|
+
};
|
|
18
|
+
};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const checkoutHiddenBtnSelector = 'zonos--checkout-hidden-button';
|
|
2
|
+
export const domesticRedirectedBtnSelector = 'zonos--domestic-redirected-checkout-button';
|
|
@@ -2265,6 +2265,15 @@ export function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
2265
2265
|
calculateLandedCost(variables, requestHeaders) {
|
|
2266
2266
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'calculateLandedCost', 'mutation');
|
|
2267
2267
|
},
|
|
2268
|
+
cart(variables, requestHeaders) {
|
|
2269
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'cart', 'query');
|
|
2270
|
+
},
|
|
2271
|
+
cartCalculateLandedCost(variables, requestHeaders) {
|
|
2272
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'cartCalculateLandedCost', 'mutation');
|
|
2273
|
+
},
|
|
2274
|
+
cartCreate(variables, requestHeaders) {
|
|
2275
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'cartCreate', 'mutation');
|
|
2276
|
+
},
|
|
2268
2277
|
checkItemRestrictions(variables, requestHeaders) {
|
|
2269
2278
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'checkItemRestrictions', 'mutation');
|
|
2270
2279
|
},
|
|
@@ -2289,6 +2298,9 @@ export function getSdk(client, withWrapper = defaultWrapper) {
|
|
|
2289
2298
|
fulfillmentCenter(variables, requestHeaders) {
|
|
2290
2299
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'fulfillmentCenter', 'query');
|
|
2291
2300
|
},
|
|
2301
|
+
getCartOrganizationInfo(variables, requestHeaders) {
|
|
2302
|
+
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'getCartOrganizationInfo', 'query');
|
|
2303
|
+
},
|
|
2292
2304
|
getCheckoutPlaceOrderButtonSelector(variables, requestHeaders) {
|
|
2293
2305
|
return withWrapper(wrappedRequestHeaders => client.request('', variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'getCheckoutPlaceOrderButtonSelector', 'query');
|
|
2294
2306
|
},
|
|
@@ -13,7 +13,7 @@ import { generateCloudflareDeployUrl } from "./generateCloudflareDeployUrl";
|
|
|
13
13
|
* - `https://<branch_name>.<project_name>.pages.dev` if is Preview
|
|
14
14
|
* - `https://route.elements.zonos.com` if is Production
|
|
15
15
|
*/
|
|
16
|
-
export const formattedCloudflareApiUrl = ({ branchName, inCI: _inCI, inVercel: _inVercel, isVercelPreview: _isVercelPreview,
|
|
16
|
+
export const formattedCloudflareApiUrl = ({ branchName, inCI: _inCI, inGithubAction, inVercel: _inVercel, isVercelPreview: _isVercelPreview, url, }) => {
|
|
17
17
|
if (!url) {
|
|
18
18
|
// return origin value so t3 can throw error when it's empty
|
|
19
19
|
return url;
|
|
@@ -24,9 +24,15 @@ export const formattedCloudflareApiUrl = ({ branchName, inCI: _inCI, inVercel: _
|
|
|
24
24
|
// local host environment, no need to format url
|
|
25
25
|
return `https://${domainOnlyUrl}`;
|
|
26
26
|
}
|
|
27
|
+
if (inGithubAction) {
|
|
28
|
+
// just use production url if it's in CI
|
|
29
|
+
return `https://${domainOnlyUrl}`;
|
|
30
|
+
}
|
|
27
31
|
const isProdBranch = branchName && ['main'].includes(branchName);
|
|
32
|
+
const isTest = domainOnlyUrl.includes('test.') || domainOnlyUrl.includes('test-git');
|
|
33
|
+
const projectName = isTest ? 'zonos-elements-test' : 'zonos-elements';
|
|
28
34
|
// always use Cloudflare preview alias if in not production environment
|
|
29
|
-
if (
|
|
35
|
+
if (!isProdBranch) {
|
|
30
36
|
// use Cloudflare branch_url instead of the production url
|
|
31
37
|
if (!branchName) {
|
|
32
38
|
throw new Error('Fail to get Cloudflare commit ref or branch name');
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export const generateCloudflareDeployUrl = ({ branchName, projectName, }) => {
|
|
8
8
|
const normalizedProjectName = projectName.toLowerCase().replace(/\s+/g, '-');
|
|
9
|
+
if (branchName === 'main') {
|
|
10
|
+
return `${normalizedProjectName}.pages.dev`;
|
|
11
|
+
}
|
|
9
12
|
// remove dots and replace non-alphanumeric characters with dashes
|
|
10
13
|
const normalizedBranchName = branchName
|
|
11
14
|
.toLowerCase()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { h as handleFetch, l as log, a as logError } from './handleFetch-37cea185.js';
|
|
2
|
+
|
|
3
|
+
const getTempCartById = async (cartId) => {
|
|
4
|
+
const { errors, json } = await handleFetch('/api/zonos-elements/get-temp-cart', {
|
|
5
|
+
body: { tempCartUUID: cartId },
|
|
6
|
+
headers: {
|
|
7
|
+
'Content-Type': 'application/json',
|
|
8
|
+
},
|
|
9
|
+
method: 'POST',
|
|
10
|
+
});
|
|
11
|
+
if (!json || errors.length) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return json;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const setupCartData = async (cartId) => {
|
|
18
|
+
const tempCartResult = await getTempCartById(cartId);
|
|
19
|
+
log('[ZONOS - loadZonos] getting temp cart data', 'info', tempCartResult);
|
|
20
|
+
if (!tempCartResult) {
|
|
21
|
+
logError('[ZONOS - loadZonos] Error getting temp cart data, stop checkout process.');
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
cartData: tempCartResult.cartData,
|
|
26
|
+
storeFavicon: tempCartResult.storeFaviconUrl,
|
|
27
|
+
storeId: tempCartResult.cartData.storeId,
|
|
28
|
+
storeLogo: tempCartResult.storeLogoUrl,
|
|
29
|
+
zonosApiKey: tempCartResult.cartData.credentialToken,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const checkoutHiddenBtnSelector = 'zonos--checkout-hidden-button';
|
|
34
|
+
const domesticRedirectedBtnSelector = 'zonos--domestic-redirected-checkout-button';
|
|
35
|
+
|
|
36
|
+
export { checkoutHiddenBtnSelector as c, domesticRedirectedBtnSelector as d, setupCartData as s };
|