@zonos/elements 1.3.50 → 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-688d674d.js → cart-61a8983d.js} +238 -370
- package/dist/cjs/{createCustomEvent-01bacaea.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-ce1516ba.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/api/triggerBuildLandedCost.js +2 -2
- package/dist/collection/components/utils/checkout/initCheckout.js +4 -2
- package/dist/collection/components/utils/handleFetch.js +6 -1
- 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-4f300fcb.js → cart-45d2861f.js} +194 -323
- package/dist/esm/{createCustomEvent-c5ed9070.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-70caf283.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-c5ed9070.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-70caf283.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/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-fe198a6c.entry.js → p-259ccf8d.entry.js} +1 -1
- package/dist/zonos-elements/p-2a47d2cc.system.entry.js +1 -0
- package/dist/zonos-elements/{p-89b1f4a5.entry.js → p-31eb835c.entry.js} +1 -1
- package/dist/zonos-elements/{p-4849604d.entry.js → p-36360905.entry.js} +1 -1
- package/dist/zonos-elements/{p-322600aa.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-31905b60.system.js → p-5590f90c.system.js} +1 -1
- package/dist/zonos-elements/p-588396df.js +1 -0
- package/dist/zonos-elements/{p-124e3426.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-d1cd0a5f.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-a67578ae.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-480a6094.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-ec31cd17.system.entry.js → p-b842b96a.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-1719bedd.entry.js → p-bb186075.entry.js} +1 -1
- package/dist/zonos-elements/{p-8af4a9e7.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-22e8d4ad.system.entry.js → p-cd4ad1be.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-e7e73693.system.entry.js → p-d62e6bb0.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-40d52dd6.system.entry.js → p-dc12f30a.system.entry.js} +1 -1
- package/dist/zonos-elements/p-eb2aedd0.js +1 -0
- package/dist/zonos-elements/{p-ceb8b836.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 +2 -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-4f300fcb.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-00f219bd.entry.js +0 -1
- package/dist/zonos-elements/p-05dff37f.js +0 -1
- package/dist/zonos-elements/p-1f2db2ff.entry.js +0 -1
- package/dist/zonos-elements/p-2018969a.js +0 -1
- package/dist/zonos-elements/p-27f2e8af.system.entry.js +0 -1
- package/dist/zonos-elements/p-4452dddc.entry.js +0 -1
- package/dist/zonos-elements/p-47c72c50.system.entry.js +0 -1
- package/dist/zonos-elements/p-595d406e.entry.js +0 -1
- package/dist/zonos-elements/p-5beccdce.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-6ab615e6.system.js +0 -1
- package/dist/zonos-elements/p-81540fd6.system.js +0 -1
- package/dist/zonos-elements/p-d709ad28.system.entry.js +0 -1
- package/dist/zonos-elements/p-eaa335e1.js +0 -1
- /package/dist/collection/types/checkout/api/{TempCart.js → NormalizedTempCart.js} +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const zonosStore = require('./zonosStore-67139f0e.js');
|
|
4
|
-
const
|
|
4
|
+
const handleFetch = require('./handleFetch-842c95b0.js');
|
|
5
5
|
const isDarkColor = require('./isDarkColor-7a056d05.js');
|
|
6
6
|
const getBorderRadius = require('./getBorderRadius-a6a3b35e.js');
|
|
7
7
|
|
|
@@ -75,6 +75,9 @@ const stringsArabic = {
|
|
|
75
75
|
'Delivery options': {
|
|
76
76
|
value: 'خيارات التوصيل',
|
|
77
77
|
},
|
|
78
|
+
Discounts: {
|
|
79
|
+
value: 'خصومات',
|
|
80
|
+
},
|
|
78
81
|
"Don't close": {
|
|
79
82
|
value: 'لا تغلق',
|
|
80
83
|
},
|
|
@@ -153,9 +156,6 @@ const stringsArabic = {
|
|
|
153
156
|
'Nothing due at the door': {
|
|
154
157
|
value: 'لا شيء مستحق عند الباب',
|
|
155
158
|
},
|
|
156
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
157
|
-
value: 'الطلبية أعلى من الحد الأدنى لكل من الرسوم والضرائب',
|
|
158
|
-
},
|
|
159
159
|
'Order total': {
|
|
160
160
|
value: 'إجمالي الطلبية',
|
|
161
161
|
},
|
|
@@ -429,6 +429,9 @@ const stringsBase = {
|
|
|
429
429
|
'Delivery options': {
|
|
430
430
|
value: 'Delivery options',
|
|
431
431
|
},
|
|
432
|
+
Discounts: {
|
|
433
|
+
value: 'Discounts',
|
|
434
|
+
},
|
|
432
435
|
"Don't close": {
|
|
433
436
|
value: "Don't close",
|
|
434
437
|
},
|
|
@@ -507,9 +510,6 @@ const stringsBase = {
|
|
|
507
510
|
'Nothing due at the door': {
|
|
508
511
|
value: 'Nothing due at the door',
|
|
509
512
|
},
|
|
510
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
511
|
-
value: 'Order is over the de minimis threshold for both duty and tax',
|
|
512
|
-
},
|
|
513
513
|
'Order total': {
|
|
514
514
|
value: 'Order total',
|
|
515
515
|
},
|
|
@@ -783,6 +783,9 @@ const stringsChinese = {
|
|
|
783
783
|
'Delivery options': {
|
|
784
784
|
value: '送货选项',
|
|
785
785
|
},
|
|
786
|
+
Discounts: {
|
|
787
|
+
value: '折扣',
|
|
788
|
+
},
|
|
786
789
|
"Don't close": {
|
|
787
790
|
value: '不要关',
|
|
788
791
|
},
|
|
@@ -861,9 +864,6 @@ const stringsChinese = {
|
|
|
861
864
|
'Nothing due at the door': {
|
|
862
865
|
value: '门口无需付款',
|
|
863
866
|
},
|
|
864
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
865
|
-
value: '订单超过关税和税款的最低征税门槛',
|
|
866
|
-
},
|
|
867
867
|
'Order total': {
|
|
868
868
|
value: '订单总计',
|
|
869
869
|
},
|
|
@@ -1137,6 +1137,9 @@ const stringsDanish = {
|
|
|
1137
1137
|
'Delivery options': {
|
|
1138
1138
|
value: 'Leveringsmuligheder',
|
|
1139
1139
|
},
|
|
1140
|
+
Discounts: {
|
|
1141
|
+
value: 'Rabat',
|
|
1142
|
+
},
|
|
1140
1143
|
"Don't close": {
|
|
1141
1144
|
value: 'Luk ikke',
|
|
1142
1145
|
},
|
|
@@ -1215,9 +1218,6 @@ const stringsDanish = {
|
|
|
1215
1218
|
'Nothing due at the door': {
|
|
1216
1219
|
value: 'Intet at betale ved døren',
|
|
1217
1220
|
},
|
|
1218
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
1219
|
-
value: 'Ordre er over de minimis-grænsen for både told og skat',
|
|
1220
|
-
},
|
|
1221
1221
|
'Order total': {
|
|
1222
1222
|
value: 'Ordresum',
|
|
1223
1223
|
},
|
|
@@ -1491,6 +1491,9 @@ const stringsDutch = {
|
|
|
1491
1491
|
'Delivery options': {
|
|
1492
1492
|
value: 'Bezorgopties',
|
|
1493
1493
|
},
|
|
1494
|
+
Discounts: {
|
|
1495
|
+
value: 'Kortingen',
|
|
1496
|
+
},
|
|
1494
1497
|
"Don't close": {
|
|
1495
1498
|
value: 'Niet sluiten',
|
|
1496
1499
|
},
|
|
@@ -1569,9 +1572,6 @@ const stringsDutch = {
|
|
|
1569
1572
|
'Nothing due at the door': {
|
|
1570
1573
|
value: 'Niets te betalen aan de deur',
|
|
1571
1574
|
},
|
|
1572
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
1573
|
-
value: 'Bestelling overschrijdt de minimale drempel voor zowel heffing als belasting',
|
|
1574
|
-
},
|
|
1575
1575
|
'Order total': {
|
|
1576
1576
|
value: 'Totaal bestelling',
|
|
1577
1577
|
},
|
|
@@ -1845,6 +1845,9 @@ const stringsFrench = {
|
|
|
1845
1845
|
'Delivery options': {
|
|
1846
1846
|
value: 'Options de livraison',
|
|
1847
1847
|
},
|
|
1848
|
+
Discounts: {
|
|
1849
|
+
value: 'Réductions',
|
|
1850
|
+
},
|
|
1848
1851
|
"Don't close": {
|
|
1849
1852
|
value: 'Ne pas fermer',
|
|
1850
1853
|
},
|
|
@@ -1923,9 +1926,6 @@ const stringsFrench = {
|
|
|
1923
1926
|
'Nothing due at the door': {
|
|
1924
1927
|
value: 'Rien à payer à la porte',
|
|
1925
1928
|
},
|
|
1926
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
1927
|
-
value: 'La commande dépasse le seuil de minimis pour les droits et les taxes',
|
|
1928
|
-
},
|
|
1929
1929
|
'Order total': {
|
|
1930
1930
|
value: 'Total de la commande',
|
|
1931
1931
|
},
|
|
@@ -2199,6 +2199,9 @@ const stringsGerman = {
|
|
|
2199
2199
|
'Delivery options': {
|
|
2200
2200
|
value: 'Lieferoptionen',
|
|
2201
2201
|
},
|
|
2202
|
+
Discounts: {
|
|
2203
|
+
value: 'Rabatte',
|
|
2204
|
+
},
|
|
2202
2205
|
"Don't close": {
|
|
2203
2206
|
value: 'Nicht schließen',
|
|
2204
2207
|
},
|
|
@@ -2277,9 +2280,6 @@ const stringsGerman = {
|
|
|
2277
2280
|
'Nothing due at the door': {
|
|
2278
2281
|
value: 'An der Tür nichts zu bezahlen',
|
|
2279
2282
|
},
|
|
2280
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
2281
|
-
value: 'Bestellung überschreitet Mindestgrenze sowohl für Zoll als auch Steuer',
|
|
2282
|
-
},
|
|
2283
2283
|
'Order total': {
|
|
2284
2284
|
value: 'Bestellsumme',
|
|
2285
2285
|
},
|
|
@@ -2553,6 +2553,9 @@ const stringsHebrew = {
|
|
|
2553
2553
|
'Delivery options': {
|
|
2554
2554
|
value: 'אפשרויות משלוח',
|
|
2555
2555
|
},
|
|
2556
|
+
Discounts: {
|
|
2557
|
+
value: 'הנחות',
|
|
2558
|
+
},
|
|
2556
2559
|
"Don't close": {
|
|
2557
2560
|
value: 'אל תסגור',
|
|
2558
2561
|
},
|
|
@@ -2631,9 +2634,6 @@ const stringsHebrew = {
|
|
|
2631
2634
|
'Nothing due at the door': {
|
|
2632
2635
|
value: 'אין כלום לשלם בדלת',
|
|
2633
2636
|
},
|
|
2634
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
2635
|
-
value: 'ההזמנה חורגת מסף המינימום גם למכס וגם למס',
|
|
2636
|
-
},
|
|
2637
2637
|
'Order total': {
|
|
2638
2638
|
value: 'סה"כ ההזמנה',
|
|
2639
2639
|
},
|
|
@@ -2907,6 +2907,9 @@ const stringsIndonesian = {
|
|
|
2907
2907
|
'Delivery options': {
|
|
2908
2908
|
value: 'Opsi pengiriman',
|
|
2909
2909
|
},
|
|
2910
|
+
Discounts: {
|
|
2911
|
+
value: 'Diskon',
|
|
2912
|
+
},
|
|
2910
2913
|
"Don't close": {
|
|
2911
2914
|
value: 'Jangan tutup',
|
|
2912
2915
|
},
|
|
@@ -2985,9 +2988,6 @@ const stringsIndonesian = {
|
|
|
2985
2988
|
'Nothing due at the door': {
|
|
2986
2989
|
value: 'Tidak ada yang harus dibayar di pintu',
|
|
2987
2990
|
},
|
|
2988
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
2989
|
-
value: 'Pesanan melebihi ambang batas de minimis untuk bea masuk dan pajak',
|
|
2990
|
-
},
|
|
2991
2991
|
'Order total': {
|
|
2992
2992
|
value: 'Total pesanan',
|
|
2993
2993
|
},
|
|
@@ -3261,6 +3261,9 @@ const stringsItalian = {
|
|
|
3261
3261
|
'Delivery options': {
|
|
3262
3262
|
value: 'Opzioni di consegna',
|
|
3263
3263
|
},
|
|
3264
|
+
Discounts: {
|
|
3265
|
+
value: 'Sconti',
|
|
3266
|
+
},
|
|
3264
3267
|
"Don't close": {
|
|
3265
3268
|
value: 'Non chiudere',
|
|
3266
3269
|
},
|
|
@@ -3339,9 +3342,6 @@ const stringsItalian = {
|
|
|
3339
3342
|
'Nothing due at the door': {
|
|
3340
3343
|
value: 'Nulla da pagare alla porta',
|
|
3341
3344
|
},
|
|
3342
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
3343
|
-
value: "L'ordine supera la soglia di minimis sia per i dazi che per le tasse",
|
|
3344
|
-
},
|
|
3345
3345
|
'Order total': {
|
|
3346
3346
|
value: 'Totale ordine',
|
|
3347
3347
|
},
|
|
@@ -3615,6 +3615,9 @@ const stringsJapanese = {
|
|
|
3615
3615
|
'Delivery options': {
|
|
3616
3616
|
value: '配送オプション',
|
|
3617
3617
|
},
|
|
3618
|
+
Discounts: {
|
|
3619
|
+
value: '割引',
|
|
3620
|
+
},
|
|
3618
3621
|
"Don't close": {
|
|
3619
3622
|
value: '閉めないでください',
|
|
3620
3623
|
},
|
|
@@ -3693,9 +3696,6 @@ const stringsJapanese = {
|
|
|
3693
3696
|
'Nothing due at the door': {
|
|
3694
3697
|
value: 'ドアでの支払いはありません',
|
|
3695
3698
|
},
|
|
3696
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
3697
|
-
value: '注文が関税と税金のデミニマス閾値を超えています',
|
|
3698
|
-
},
|
|
3699
3699
|
'Order total': {
|
|
3700
3700
|
value: 'ご注文合計',
|
|
3701
3701
|
},
|
|
@@ -3969,6 +3969,9 @@ const stringsKorean = {
|
|
|
3969
3969
|
'Delivery options': {
|
|
3970
3970
|
value: '배송 옵션',
|
|
3971
3971
|
},
|
|
3972
|
+
Discounts: {
|
|
3973
|
+
value: '할인',
|
|
3974
|
+
},
|
|
3972
3975
|
"Don't close": {
|
|
3973
3976
|
value: '닫지 마세요',
|
|
3974
3977
|
},
|
|
@@ -4047,9 +4050,6 @@ const stringsKorean = {
|
|
|
4047
4050
|
'Nothing due at the door': {
|
|
4048
4051
|
value: '문 앞에 납부할 것이 없습니다',
|
|
4049
4052
|
},
|
|
4050
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
4051
|
-
value: '주문 금액이 관세와 세금의 최저 임계값을 초과합니다',
|
|
4052
|
-
},
|
|
4053
4053
|
'Order total': {
|
|
4054
4054
|
value: '주문 총액',
|
|
4055
4055
|
},
|
|
@@ -4323,6 +4323,9 @@ const stringsNorwegian = {
|
|
|
4323
4323
|
'Delivery options': {
|
|
4324
4324
|
value: 'Leveringsalternativer',
|
|
4325
4325
|
},
|
|
4326
|
+
Discounts: {
|
|
4327
|
+
value: 'Rabatter',
|
|
4328
|
+
},
|
|
4326
4329
|
"Don't close": {
|
|
4327
4330
|
value: 'Ikke lukk',
|
|
4328
4331
|
},
|
|
@@ -4401,9 +4404,6 @@ const stringsNorwegian = {
|
|
|
4401
4404
|
'Nothing due at the door': {
|
|
4402
4405
|
value: 'Ingenting å betale ved døren',
|
|
4403
4406
|
},
|
|
4404
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
4405
|
-
value: 'Bestillingen er over minstegrensen for både avgift og skatt',
|
|
4406
|
-
},
|
|
4407
4407
|
'Order total': {
|
|
4408
4408
|
value: 'Totalt beløp',
|
|
4409
4409
|
},
|
|
@@ -4677,6 +4677,9 @@ const stringsPolish = {
|
|
|
4677
4677
|
'Delivery options': {
|
|
4678
4678
|
value: 'Opcje dostawy',
|
|
4679
4679
|
},
|
|
4680
|
+
Discounts: {
|
|
4681
|
+
value: 'Zniżki',
|
|
4682
|
+
},
|
|
4680
4683
|
"Don't close": {
|
|
4681
4684
|
value: 'Nie zamykaj',
|
|
4682
4685
|
},
|
|
@@ -4755,9 +4758,6 @@ const stringsPolish = {
|
|
|
4755
4758
|
'Nothing due at the door': {
|
|
4756
4759
|
value: 'Nic do zapłacenia przy drzwiach',
|
|
4757
4760
|
},
|
|
4758
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
4759
|
-
value: 'Zamówienie przekracza próg minimalny zarówno dla cła, jak i podatku',
|
|
4760
|
-
},
|
|
4761
4761
|
'Order total': {
|
|
4762
4762
|
value: 'Łączna kwota zamówienia',
|
|
4763
4763
|
},
|
|
@@ -5031,6 +5031,9 @@ const stringsPortuguese = {
|
|
|
5031
5031
|
'Delivery options': {
|
|
5032
5032
|
value: 'Opções de entrega',
|
|
5033
5033
|
},
|
|
5034
|
+
Discounts: {
|
|
5035
|
+
value: 'Descontos',
|
|
5036
|
+
},
|
|
5034
5037
|
"Don't close": {
|
|
5035
5038
|
value: 'Não fechar',
|
|
5036
5039
|
},
|
|
@@ -5109,9 +5112,6 @@ const stringsPortuguese = {
|
|
|
5109
5112
|
'Nothing due at the door': {
|
|
5110
5113
|
value: 'Nada a pagar na porta',
|
|
5111
5114
|
},
|
|
5112
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
5113
|
-
value: 'O pedido ultrapassa o limite de isenção tanto para impostos quanto para taxas',
|
|
5114
|
-
},
|
|
5115
5115
|
'Order total': {
|
|
5116
5116
|
value: 'Total do pedido',
|
|
5117
5117
|
},
|
|
@@ -5385,6 +5385,9 @@ const stringsRussian = {
|
|
|
5385
5385
|
'Delivery options': {
|
|
5386
5386
|
value: 'Варианты доставки',
|
|
5387
5387
|
},
|
|
5388
|
+
Discounts: {
|
|
5389
|
+
value: 'Скидки',
|
|
5390
|
+
},
|
|
5388
5391
|
"Don't close": {
|
|
5389
5392
|
value: 'Не закрывайте',
|
|
5390
5393
|
},
|
|
@@ -5463,9 +5466,6 @@ const stringsRussian = {
|
|
|
5463
5466
|
'Nothing due at the door': {
|
|
5464
5467
|
value: 'На двери ничего не должно',
|
|
5465
5468
|
},
|
|
5466
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
5467
|
-
value: 'Заказ превышает минимальный порог как для пошлины, так и для налога',
|
|
5468
|
-
},
|
|
5469
5469
|
'Order total': {
|
|
5470
5470
|
value: 'Итого',
|
|
5471
5471
|
},
|
|
@@ -5739,6 +5739,9 @@ const stringsSpanish = {
|
|
|
5739
5739
|
'Delivery options': {
|
|
5740
5740
|
value: 'Opciones de entrega',
|
|
5741
5741
|
},
|
|
5742
|
+
Discounts: {
|
|
5743
|
+
value: 'Descuentos',
|
|
5744
|
+
},
|
|
5742
5745
|
"Don't close": {
|
|
5743
5746
|
value: 'No cerrar',
|
|
5744
5747
|
},
|
|
@@ -5817,9 +5820,6 @@ const stringsSpanish = {
|
|
|
5817
5820
|
'Nothing due at the door': {
|
|
5818
5821
|
value: 'Nada debido en la puerta',
|
|
5819
5822
|
},
|
|
5820
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
5821
|
-
value: 'El pedido supera el umbral mínimo tanto para impuestos como para aranceles',
|
|
5822
|
-
},
|
|
5823
5823
|
'Order total': {
|
|
5824
5824
|
value: 'Total del pedido',
|
|
5825
5825
|
},
|
|
@@ -6093,6 +6093,9 @@ const stringsSwedish = {
|
|
|
6093
6093
|
'Delivery options': {
|
|
6094
6094
|
value: 'Leveransalternativ',
|
|
6095
6095
|
},
|
|
6096
|
+
Discounts: {
|
|
6097
|
+
value: 'Rabatter',
|
|
6098
|
+
},
|
|
6096
6099
|
"Don't close": {
|
|
6097
6100
|
value: 'Stäng inte',
|
|
6098
6101
|
},
|
|
@@ -6171,9 +6174,6 @@ const stringsSwedish = {
|
|
|
6171
6174
|
'Nothing due at the door': {
|
|
6172
6175
|
value: 'Ingenting att betala vid dörren',
|
|
6173
6176
|
},
|
|
6174
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
6175
|
-
value: 'Beställningen överstiger minimibeloppet för både tull och skatt',
|
|
6176
|
-
},
|
|
6177
6177
|
'Order total': {
|
|
6178
6178
|
value: 'Totalt belopp för beställningen',
|
|
6179
6179
|
},
|
|
@@ -6447,6 +6447,9 @@ const stringsTurkish = {
|
|
|
6447
6447
|
'Delivery options': {
|
|
6448
6448
|
value: 'Teslimat seçenekleri',
|
|
6449
6449
|
},
|
|
6450
|
+
Discounts: {
|
|
6451
|
+
value: 'İndirimler',
|
|
6452
|
+
},
|
|
6450
6453
|
"Don't close": {
|
|
6451
6454
|
value: 'Kapatma',
|
|
6452
6455
|
},
|
|
@@ -6525,9 +6528,6 @@ const stringsTurkish = {
|
|
|
6525
6528
|
'Nothing due at the door': {
|
|
6526
6529
|
value: 'Kapıda ödenecek bir şey yok',
|
|
6527
6530
|
},
|
|
6528
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
6529
|
-
value: 'Sipariş hem gümrük hem vergi için minimum sınırın üzerinde',
|
|
6530
|
-
},
|
|
6531
6531
|
'Order total': {
|
|
6532
6532
|
value: 'Sipariş toplamı',
|
|
6533
6533
|
},
|
|
@@ -6801,6 +6801,9 @@ const stringsVietnamese = {
|
|
|
6801
6801
|
'Delivery options': {
|
|
6802
6802
|
value: 'Tùy chọn giao hàng',
|
|
6803
6803
|
},
|
|
6804
|
+
Discounts: {
|
|
6805
|
+
value: 'Giảm giá',
|
|
6806
|
+
},
|
|
6804
6807
|
"Don't close": {
|
|
6805
6808
|
value: 'Đừng đóng',
|
|
6806
6809
|
},
|
|
@@ -6879,9 +6882,6 @@ const stringsVietnamese = {
|
|
|
6879
6882
|
'Nothing due at the door': {
|
|
6880
6883
|
value: 'Không có gì phải trả tại cửa',
|
|
6881
6884
|
},
|
|
6882
|
-
'Order is over the de minimis threshold for both duty and tax': {
|
|
6883
|
-
value: 'Đơn hàng vượt ngưỡng miễn thuế cho cả thuế nhập khẩu và thuế',
|
|
6884
|
-
},
|
|
6885
6885
|
'Order total': {
|
|
6886
6886
|
value: 'Tổng đơn hàng',
|
|
6887
6887
|
},
|
|
@@ -7173,264 +7173,9 @@ const translate = (...[key, replacement]) => {
|
|
|
7173
7173
|
return ((_b = translationStore.translatedChunks[key]) === null || _b === void 0 ? void 0 : _b.value) || key;
|
|
7174
7174
|
};
|
|
7175
7175
|
|
|
7176
|
-
const fallbackApiType = ['cloudflare', 'vercel'];
|
|
7177
|
-
const MAIN_BASE_API_TYPE = fallbackApiType[0];
|
|
7178
|
-
const fallbackApiList = {
|
|
7179
|
-
cloudflare: "https://route.elements.zonos.com",
|
|
7180
|
-
vercel: "https://v1.route.js.zonos.com",
|
|
7181
|
-
};
|
|
7182
|
-
const MAIN_BASE_API = fallbackApiList[MAIN_BASE_API_TYPE];
|
|
7183
|
-
/**
|
|
7184
|
-
* Next available fallback api type
|
|
7185
|
-
*/
|
|
7186
|
-
const getNextFallbackApiType = (currentApiType = MAIN_BASE_API_TYPE) => {
|
|
7187
|
-
const currentIndex = fallbackApiType.indexOf(currentApiType);
|
|
7188
|
-
const nextFallbackApiType = fallbackApiType[currentIndex + 1];
|
|
7189
|
-
if (!nextFallbackApiType) {
|
|
7190
|
-
return null;
|
|
7191
|
-
}
|
|
7192
|
-
return nextFallbackApiType;
|
|
7193
|
-
};
|
|
7194
|
-
|
|
7195
|
-
const jsonParse = (_data) => {
|
|
7196
|
-
if (typeof _data === 'string') {
|
|
7197
|
-
try {
|
|
7198
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
7199
|
-
const json = JSON.parse(_data);
|
|
7200
|
-
return json;
|
|
7201
|
-
}
|
|
7202
|
-
catch (_error) {
|
|
7203
|
-
return null;
|
|
7204
|
-
}
|
|
7205
|
-
}
|
|
7206
|
-
return null;
|
|
7207
|
-
};
|
|
7208
|
-
|
|
7209
|
-
/**
|
|
7210
|
-
* This is the time in milliseconds after release time that we will start sending error logs to the new API
|
|
7211
|
-
* @default 1 hour
|
|
7212
|
-
*/
|
|
7213
|
-
const postReleaseReportingDuration = 1 * 3600 * 1000; // 1 hour
|
|
7214
|
-
const sendErrorLog = async ({ endpoint, errors, metadata, shouldPostReleaseErrorReporting, }) => {
|
|
7215
|
-
if (shouldPostReleaseErrorReporting) {
|
|
7216
|
-
// We only want to report errors that happened if current time is less than 2 hours after release time
|
|
7217
|
-
const releaseTime = Number(window.Zonos.releaseDate);
|
|
7218
|
-
const currentTime = new Date().getTime();
|
|
7219
|
-
if (currentTime - releaseTime > postReleaseReportingDuration) {
|
|
7220
|
-
return;
|
|
7221
|
-
}
|
|
7222
|
-
}
|
|
7223
|
-
const userAgentData = 'userAgentData' in window.navigator
|
|
7224
|
-
? // userAgentData is not yet supported in all browsers
|
|
7225
|
-
window.navigator.userAgentData
|
|
7226
|
-
: null;
|
|
7227
|
-
const errorObject = {
|
|
7228
|
-
endpoint,
|
|
7229
|
-
errors,
|
|
7230
|
-
metadata: Object.assign({ href: window.location.href, userAgent: userAgentData && userAgentData.brands.length > 0
|
|
7231
|
-
? userAgentData
|
|
7232
|
-
: window.navigator.userAgent }, metadata),
|
|
7233
|
-
};
|
|
7234
|
-
try {
|
|
7235
|
-
// use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
|
|
7236
|
-
void fetch(`${MAIN_BASE_API}/api/zonos-elements/log-error`, {
|
|
7237
|
-
body: JSON.stringify(errorObject),
|
|
7238
|
-
method: 'POST',
|
|
7239
|
-
});
|
|
7240
|
-
}
|
|
7241
|
-
catch (_err) {
|
|
7242
|
-
const nextFallbackApi = getNextFallbackApiType();
|
|
7243
|
-
if (!nextFallbackApi) {
|
|
7244
|
-
return;
|
|
7245
|
-
}
|
|
7246
|
-
// request to the fallback API if the first one fails
|
|
7247
|
-
void fetch(`${fallbackApiList[nextFallbackApi]}/api/zonos-elements/log-error`, {
|
|
7248
|
-
body: JSON.stringify(errorObject),
|
|
7249
|
-
method: 'POST',
|
|
7250
|
-
});
|
|
7251
|
-
}
|
|
7252
|
-
};
|
|
7253
|
-
|
|
7254
|
-
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
7255
|
-
var t = {};
|
|
7256
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
7257
|
-
t[p] = s[p];
|
|
7258
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7259
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7260
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
7261
|
-
t[p[i]] = s[p[i]];
|
|
7262
|
-
}
|
|
7263
|
-
return t;
|
|
7264
|
-
};
|
|
7265
|
-
const getResponseBody = async ({ response, shouldLog = true, shouldThrow = false, }) => {
|
|
7266
|
-
try {
|
|
7267
|
-
const json = await response.json();
|
|
7268
|
-
return json;
|
|
7269
|
-
}
|
|
7270
|
-
catch (e) {
|
|
7271
|
-
if (shouldThrow) {
|
|
7272
|
-
throw e;
|
|
7273
|
-
}
|
|
7274
|
-
if (shouldLog) {
|
|
7275
|
-
// eslint-disable-next-line
|
|
7276
|
-
console.error(e);
|
|
7277
|
-
}
|
|
7278
|
-
return null;
|
|
7279
|
-
}
|
|
7280
|
-
};
|
|
7281
|
-
const encodeString = (text) => {
|
|
7282
|
-
try {
|
|
7283
|
-
// encode the string, remove the "=" at the end of the encoded string
|
|
7284
|
-
const encodedString = btoa(text).replace(/=/g, '');
|
|
7285
|
-
return encodedString;
|
|
7286
|
-
}
|
|
7287
|
-
catch (error) {
|
|
7288
|
-
// return the reverse string if the encoding failed
|
|
7289
|
-
return text
|
|
7290
|
-
.replace(/[^A-Za-z0-9]/g, '')
|
|
7291
|
-
.split('')
|
|
7292
|
-
.reverse()
|
|
7293
|
-
.join('');
|
|
7294
|
-
}
|
|
7295
|
-
};
|
|
7296
|
-
const handleRequest = async ({ basePathType, options, path, }) => {
|
|
7297
|
-
let response;
|
|
7298
|
-
// fallback to the main base API if the passed in base path is not available
|
|
7299
|
-
const baseUrl = fallbackApiList[basePathType] || MAIN_BASE_API_TYPE;
|
|
7300
|
-
const url = baseUrl + path;
|
|
7301
|
-
// adding random encoded token to the url so that the request will be cached differently for each store
|
|
7302
|
-
const modifiedUrl = new URL(url);
|
|
7303
|
-
modifiedUrl.searchParams.set('zToken', encodeString(window.location.hostname));
|
|
7304
|
-
try {
|
|
7305
|
-
response = await fetch(modifiedUrl.toString(), options);
|
|
7306
|
-
}
|
|
7307
|
-
catch (e) {
|
|
7308
|
-
if (e instanceof Error) {
|
|
7309
|
-
return {
|
|
7310
|
-
baseUrl,
|
|
7311
|
-
errors: [{ message: e.message, type: 'unknown' }],
|
|
7312
|
-
json: null,
|
|
7313
|
-
response: null,
|
|
7314
|
-
zonosMode: null,
|
|
7315
|
-
};
|
|
7316
|
-
}
|
|
7317
|
-
const message = 'Fail to fetch';
|
|
7318
|
-
return {
|
|
7319
|
-
baseUrl,
|
|
7320
|
-
errors: [{ message, type: 'unknown' }],
|
|
7321
|
-
json: null,
|
|
7322
|
-
response: null,
|
|
7323
|
-
zonosMode: null,
|
|
7324
|
-
};
|
|
7325
|
-
}
|
|
7326
|
-
const zonosMode = response.headers.get('Zonos-Mode');
|
|
7327
|
-
const usingZonosPreview = window.Zonos.zonosQaUrl;
|
|
7328
|
-
// We only want to alert once if the user is in preview mode and it's also using production environment
|
|
7329
|
-
if (!window.Zonos.modeAlerted && zonosMode && usingZonosPreview) {
|
|
7330
|
-
window.Zonos.modeAlerted = true;
|
|
7331
|
-
}
|
|
7332
|
-
if (response.ok) {
|
|
7333
|
-
const data = await getResponseBody({ response });
|
|
7334
|
-
return {
|
|
7335
|
-
baseUrl,
|
|
7336
|
-
errors: [],
|
|
7337
|
-
json: data,
|
|
7338
|
-
response,
|
|
7339
|
-
zonosMode,
|
|
7340
|
-
};
|
|
7341
|
-
}
|
|
7342
|
-
const status = response.status.toString();
|
|
7343
|
-
try {
|
|
7344
|
-
const data = await getResponseBody({
|
|
7345
|
-
response,
|
|
7346
|
-
shouldThrow: true,
|
|
7347
|
-
});
|
|
7348
|
-
const message = JSON.stringify(data);
|
|
7349
|
-
return {
|
|
7350
|
-
baseUrl,
|
|
7351
|
-
errors: [{ message, type: status }],
|
|
7352
|
-
json: null,
|
|
7353
|
-
response,
|
|
7354
|
-
zonosMode,
|
|
7355
|
-
};
|
|
7356
|
-
}
|
|
7357
|
-
catch (e) {
|
|
7358
|
-
const message = 'Unknown error';
|
|
7359
|
-
return {
|
|
7360
|
-
baseUrl,
|
|
7361
|
-
errors: [{ message: `${status}: ${message}`, type: status }],
|
|
7362
|
-
json: null,
|
|
7363
|
-
response: null,
|
|
7364
|
-
zonosMode,
|
|
7365
|
-
};
|
|
7366
|
-
}
|
|
7367
|
-
};
|
|
7368
|
-
const handleRequestWithFallback = async ({ basePathType, options, path, }) => {
|
|
7369
|
-
var _a, _b;
|
|
7370
|
-
const _c = await handleRequest({
|
|
7371
|
-
basePathType,
|
|
7372
|
-
options,
|
|
7373
|
-
path,
|
|
7374
|
-
}), { errors, response } = _c, rest = __rest(_c, ["errors", "response"]);
|
|
7375
|
-
const nextFallbackApiType = getNextFallbackApiType(basePathType);
|
|
7376
|
-
const unknownError = errors.find(({ type }) => type === 'unknown');
|
|
7377
|
-
const isUnknownError = !!unknownError || (response === null || response === void 0 ? void 0 : response.status) === 404;
|
|
7378
|
-
const shouldCallFallback =
|
|
7379
|
-
// If next fallback is available, and the error is unknown (fail to fetch) or 404
|
|
7380
|
-
nextFallbackApiType && isUnknownError;
|
|
7381
|
-
// Should log the error if it's unknown error
|
|
7382
|
-
if (isUnknownError) {
|
|
7383
|
-
void sendErrorLog({
|
|
7384
|
-
endpoint: fallbackApiList[basePathType] + path,
|
|
7385
|
-
errors: errors.map(({ message }) => message),
|
|
7386
|
-
metadata: {
|
|
7387
|
-
currentBasePath: basePathType,
|
|
7388
|
-
nextFallbackApiType,
|
|
7389
|
-
requestHeaders: options === null || options === void 0 ? void 0 : options.headers,
|
|
7390
|
-
requestPayload: jsonParse((_a = options === null || options === void 0 ? void 0 : options.body) === null || _a === void 0 ? void 0 : _a.toString()) || ((_b = options === null || options === void 0 ? void 0 : options.body) === null || _b === void 0 ? void 0 : _b.toString()),
|
|
7391
|
-
status: response === null || response === void 0 ? void 0 : response.status,
|
|
7392
|
-
statusText: response === null || response === void 0 ? void 0 : response.statusText,
|
|
7393
|
-
},
|
|
7394
|
-
// When the error is unknown, error reporting should be enabled for period of time after release, so we can monitor the error.
|
|
7395
|
-
shouldPostReleaseErrorReporting: true,
|
|
7396
|
-
});
|
|
7397
|
-
}
|
|
7398
|
-
if (shouldCallFallback) {
|
|
7399
|
-
logError.log(`=== "${path}" failed to fetch, trying next fallback ${nextFallbackApiType}`);
|
|
7400
|
-
return handleRequestWithFallback({
|
|
7401
|
-
basePathType: nextFallbackApiType,
|
|
7402
|
-
options,
|
|
7403
|
-
path,
|
|
7404
|
-
});
|
|
7405
|
-
}
|
|
7406
|
-
// No more fallbacks, just return the result
|
|
7407
|
-
return Object.assign({ errors, response }, rest);
|
|
7408
|
-
};
|
|
7409
|
-
/**
|
|
7410
|
-
* Fetch request and will request to fallback API when the first one fails
|
|
7411
|
-
* @param path Path name of the request (e.g. /api/something/com).
|
|
7412
|
-
* @param _opts fetch options
|
|
7413
|
-
*/
|
|
7414
|
-
const handleFetch = async (path, _opts) => {
|
|
7415
|
-
const opts = __rest(_opts || {}, []);
|
|
7416
|
-
const body = opts.body ? JSON.stringify(opts.body) : undefined;
|
|
7417
|
-
const method = opts.method || 'GET';
|
|
7418
|
-
// headers content type
|
|
7419
|
-
const headers = Object.assign({ 'Content-Type': 'application/json', 'Zonos-Is-BigCommerce': window.Zonos.isBigCommerce.toString(), 'Zonos-Referer': window.location.hostname, 'Zonos-Version': window.Zonos.version, credentialtoken: window.Zonos.zonosApiKey || 'Empty credential token from zonos-elements' }, opts.headers);
|
|
7420
|
-
const options = Object.assign(Object.assign({}, opts), { body: method === 'GET' ? undefined : body, headers,
|
|
7421
|
-
method });
|
|
7422
|
-
// This is for testing fallback API, set fallback API type to start with
|
|
7423
|
-
const useFallbackApi = new URLSearchParams(window.location.search).get('useFallbackApi');
|
|
7424
|
-
return handleRequestWithFallback({
|
|
7425
|
-
basePathType: useFallbackApi || MAIN_BASE_API_TYPE,
|
|
7426
|
-
options,
|
|
7427
|
-
path,
|
|
7428
|
-
});
|
|
7429
|
-
};
|
|
7430
|
-
|
|
7431
7176
|
const getCountries = async () => {
|
|
7432
7177
|
try {
|
|
7433
|
-
const { errors, json } = await handleFetch('/api/zonos-elements/get-countries', {
|
|
7178
|
+
const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/get-countries', {
|
|
7434
7179
|
method: 'GET',
|
|
7435
7180
|
});
|
|
7436
7181
|
if (errors.length || !json) {
|
|
@@ -7449,9 +7194,9 @@ const getCountryLandedCost = async (countryCode) => {
|
|
|
7449
7194
|
return null;
|
|
7450
7195
|
}
|
|
7451
7196
|
const url = `/api/zonos-elements/country-landed-cost/${countryCode}`;
|
|
7452
|
-
const { errors, json } = await handleFetch(url);
|
|
7197
|
+
const { errors, json } = await handleFetch.handleFetch(url);
|
|
7453
7198
|
if (errors.length || !json) {
|
|
7454
|
-
|
|
7199
|
+
handleFetch.logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
7455
7200
|
return null;
|
|
7456
7201
|
}
|
|
7457
7202
|
return json || null;
|
|
@@ -7482,9 +7227,9 @@ const getExchangeRate = async ({ country, isGuaranteed, sourceCurrency, targetCu
|
|
|
7482
7227
|
searchParams.set('targetCurrency', targetCurrency);
|
|
7483
7228
|
searchParams.set('isGuaranteed', String(isGuaranteed));
|
|
7484
7229
|
searchParams.set('country', country || '');
|
|
7485
|
-
const { errors, json } = await handleFetch(`/api/zonos-elements/exchange-rates?${searchParams.toString()}`);
|
|
7230
|
+
const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/exchange-rates?${searchParams.toString()}`);
|
|
7486
7231
|
if (errors.length || !json) {
|
|
7487
|
-
|
|
7232
|
+
handleFetch.logError(`Error fetching country landed cost: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
7488
7233
|
return defaultUsExchangeRate;
|
|
7489
7234
|
}
|
|
7490
7235
|
const { rate, targetFormat } = json.exchangeRateCreate;
|
|
@@ -7502,9 +7247,9 @@ const getInclusivePricing = async (countryCode) => {
|
|
|
7502
7247
|
if (!countryCode) {
|
|
7503
7248
|
return null;
|
|
7504
7249
|
}
|
|
7505
|
-
const { errors, json } = await handleFetch(`/api/zonos-elements/inclusive-prices/${countryCode}`);
|
|
7250
|
+
const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/inclusive-prices/${countryCode}`);
|
|
7506
7251
|
if (errors.length || !json) {
|
|
7507
|
-
|
|
7252
|
+
handleFetch.logError(`Error fetching country inclusive price setting: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
7508
7253
|
return null;
|
|
7509
7254
|
}
|
|
7510
7255
|
return json || null;
|
|
@@ -7518,9 +7263,9 @@ const getLocaleMessages = async ({ countryCode, localeTo, storeId, }) => {
|
|
|
7518
7263
|
if (localeTo) {
|
|
7519
7264
|
searchParams.set('localeTo', localeTo);
|
|
7520
7265
|
}
|
|
7521
|
-
const { errors, json } = await handleFetch(`/api/zonos-elements/locale-messages?${searchParams.toString()}`);
|
|
7266
|
+
const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/locale-messages?${searchParams.toString()}`);
|
|
7522
7267
|
if (errors.length || !json) {
|
|
7523
|
-
|
|
7268
|
+
handleFetch.logError('Error fetching exchange rate', (_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message);
|
|
7524
7269
|
return [];
|
|
7525
7270
|
}
|
|
7526
7271
|
return json.locale_countryCodesPage;
|
|
@@ -7542,7 +7287,7 @@ const getLocalization = async () => {
|
|
|
7542
7287
|
if (zCountry) {
|
|
7543
7288
|
searchParams.set('zCountry', zCountry);
|
|
7544
7289
|
}
|
|
7545
|
-
const { errors, json } = await handleFetch(`/api/zonos-elements/localization?${searchParams.toString()}`);
|
|
7290
|
+
const { errors, json } = await handleFetch.handleFetch(`/api/zonos-elements/localization?${searchParams.toString()}`);
|
|
7546
7291
|
if (errors.length || !json) {
|
|
7547
7292
|
return { country: null, locale: null };
|
|
7548
7293
|
}
|
|
@@ -7558,9 +7303,9 @@ const getLocalization = async () => {
|
|
|
7558
7303
|
|
|
7559
7304
|
const getShippingZones = async () => {
|
|
7560
7305
|
var _a, _b;
|
|
7561
|
-
const { errors, json } = await handleFetch('/api/zonos-elements/shipping-zones');
|
|
7306
|
+
const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/shipping-zones');
|
|
7562
7307
|
if (errors.length || !json) {
|
|
7563
|
-
|
|
7308
|
+
handleFetch.logError(`Error fetching shipping zones: ${(_a = errors.find(Boolean)) === null || _a === void 0 ? void 0 : _a.message}`);
|
|
7564
7309
|
return null;
|
|
7565
7310
|
}
|
|
7566
7311
|
const shippingZones = (_b = json === null || json === void 0 ? void 0 : json.shippingZones) === null || _b === void 0 ? void 0 : _b.flatMap(zone => zone === null || zone === void 0 ? void 0 : zone.countryCodes).filter(Boolean);
|
|
@@ -7683,12 +7428,12 @@ const isValidSelector = (selector) => {
|
|
|
7683
7428
|
const getCurrencyElements = (selector) => {
|
|
7684
7429
|
const currencySelector = selector || '.money';
|
|
7685
7430
|
if (!isValidSelector(currencySelector)) {
|
|
7686
|
-
|
|
7431
|
+
handleFetch.logError(`Currency element selector "${currencySelector}" is not valid.`);
|
|
7687
7432
|
return null;
|
|
7688
7433
|
}
|
|
7689
7434
|
const currencyElements = document.querySelectorAll(currencySelector);
|
|
7690
7435
|
if (!currencyElements.length) {
|
|
7691
|
-
|
|
7436
|
+
handleFetch.log(`No currency elements found with selector "${currencySelector}"`, 'warn');
|
|
7692
7437
|
return null;
|
|
7693
7438
|
}
|
|
7694
7439
|
// return array of currency elements instead of a NodeList
|
|
@@ -7766,7 +7511,7 @@ const defaultCurrencyConverter = () => {
|
|
|
7766
7511
|
return;
|
|
7767
7512
|
}
|
|
7768
7513
|
if (!localizationStore.exchangeRate) {
|
|
7769
|
-
|
|
7514
|
+
handleFetch.logError('Could not display currency. Exchange rate and format data is not available.');
|
|
7770
7515
|
return;
|
|
7771
7516
|
}
|
|
7772
7517
|
currencyElements.forEach(element => {
|
|
@@ -7853,13 +7598,13 @@ const startExchangeRateTimeout = ({ isGuaranteed, maxAge, }) => {
|
|
|
7853
7598
|
};
|
|
7854
7599
|
const getNewLocalization = async () => {
|
|
7855
7600
|
var _a;
|
|
7856
|
-
|
|
7601
|
+
handleFetch.log('get new localization store');
|
|
7857
7602
|
const { isShippableCountry, selectedCountryCode } = localizationStore;
|
|
7858
7603
|
localizationStore.countryLandedCost = await getCountryLandedCost(localizationStore.selectedCountryCode);
|
|
7859
7604
|
localizationStore.inclusivePricing =
|
|
7860
7605
|
((_a = (await getInclusivePricing(selectedCountryCode))) === null || _a === void 0 ? void 0 : _a.setting) || null;
|
|
7861
7606
|
if (localizationStore.inclusivePricing) {
|
|
7862
|
-
|
|
7607
|
+
handleFetch.log(`Inclusive price setting found for this country (${selectedCountryCode}) ${JSON.stringify(localizationStore.inclusivePricing, null, 2)}`);
|
|
7863
7608
|
}
|
|
7864
7609
|
if (zonosStore.zonosStore.helloSettings.currencyBehavior === 'DISABLED' ||
|
|
7865
7610
|
!isShippableCountry ||
|
|
@@ -7904,7 +7649,7 @@ const addInternationalHideClass = () => {
|
|
|
7904
7649
|
};
|
|
7905
7650
|
const localizationStoreUpdateSelectedCountryCode = (newSelectedCountryCode) => {
|
|
7906
7651
|
var _a, _b;
|
|
7907
|
-
|
|
7652
|
+
handleFetch.log(`Updating selected country code to ${newSelectedCountryCode}`);
|
|
7908
7653
|
const isFirstTime = !localizationStore.selectedCountryCode;
|
|
7909
7654
|
localizationStore.selectedCountryCode = newSelectedCountryCode;
|
|
7910
7655
|
const { selectedCountryCode, shippingZoneCountries } = localizationStore;
|
|
@@ -7913,7 +7658,7 @@ const localizationStoreUpdateSelectedCountryCode = (newSelectedCountryCode) => {
|
|
|
7913
7658
|
!!shippingZoneCountries[selectedCountryCode];
|
|
7914
7659
|
// update shippable country
|
|
7915
7660
|
localizationStore.isShippableCountry = !!isShippableCountry;
|
|
7916
|
-
|
|
7661
|
+
handleFetch.log(`${localizationStore.selectedCountryCode} is shippable country: ${localizationStore.isShippableCountry}`);
|
|
7917
7662
|
addInternationalHideClass();
|
|
7918
7663
|
if (!selectedCountryCode) {
|
|
7919
7664
|
return;
|
|
@@ -7997,7 +7742,7 @@ const updateCheckoutSessionLanguage = async () => {
|
|
|
7997
7742
|
if (!cartStore.checkoutSessionId) {
|
|
7998
7743
|
return null;
|
|
7999
7744
|
}
|
|
8000
|
-
const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
|
|
7745
|
+
const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/update-checkout-session-metadata', {
|
|
8001
7746
|
body: {
|
|
8002
7747
|
id: cartStore.checkoutSessionId,
|
|
8003
7748
|
metadata: [
|
|
@@ -8010,7 +7755,7 @@ const updateCheckoutSessionLanguage = async () => {
|
|
|
8010
7755
|
method: 'POST',
|
|
8011
7756
|
});
|
|
8012
7757
|
if (errors.length || !json) {
|
|
8013
|
-
|
|
7758
|
+
handleFetch.logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
|
|
8014
7759
|
return { errors, json };
|
|
8015
7760
|
}
|
|
8016
7761
|
return { errors: [], json };
|
|
@@ -8040,6 +7785,71 @@ const getTranslatedAddress = ({ currentAddress, translatedAddress, }) => {
|
|
|
8040
7785
|
state: ((_f = translatedAddress.state) === null || _f === void 0 ? void 0 : _f[state]) || state,
|
|
8041
7786
|
};
|
|
8042
7787
|
};
|
|
7788
|
+
/**
|
|
7789
|
+
* Similar to prepCalculateLandedCost except it only uses
|
|
7790
|
+
*/
|
|
7791
|
+
const prepCartCalculateLandedCost = (cartId) => {
|
|
7792
|
+
var _a;
|
|
7793
|
+
// maybe we don't need email now for prefetch the landed cost
|
|
7794
|
+
const stripeLinkData = stripeStore.stripeLinkEventData;
|
|
7795
|
+
const stripeAddressData = stripeStore.stripeAddressEventData;
|
|
7796
|
+
const stripeBillingAddressData = stripeStore.stripeShippingSameAsBilling
|
|
7797
|
+
? stripeStore.stripeAddressEventData
|
|
7798
|
+
: stripeStore.stripeBillingAddressEventData;
|
|
7799
|
+
if (!(stripeAddressData === null || stripeAddressData === void 0 ? void 0 : stripeAddressData.complete) || !(stripeBillingAddressData === null || stripeBillingAddressData === void 0 ? void 0 : stripeBillingAddressData.complete)) {
|
|
7800
|
+
throw new Error('Missing stripe address data');
|
|
7801
|
+
}
|
|
7802
|
+
// Attempt to get translated address if available
|
|
7803
|
+
const translatedShippingAddress = getTranslatedAddress({
|
|
7804
|
+
currentAddress: stripeAddressData,
|
|
7805
|
+
translatedAddress: stripeStore.translatedAddress.address,
|
|
7806
|
+
});
|
|
7807
|
+
const shippingFirstName = translatedShippingAddress.name.split(' ')[0] || '';
|
|
7808
|
+
const shippingLastName = translatedShippingAddress.name.split(' ').splice(1).join(' ') || '';
|
|
7809
|
+
const translatedBillingAddress = getTranslatedAddress({
|
|
7810
|
+
currentAddress: stripeBillingAddressData,
|
|
7811
|
+
translatedAddress: stripeStore.translatedAddress.address,
|
|
7812
|
+
});
|
|
7813
|
+
const billingFirstName = translatedBillingAddress.name.split(' ')[0] || '';
|
|
7814
|
+
const billingLastName = translatedBillingAddress.name.split(' ').splice(1).join(' ') || '';
|
|
7815
|
+
return {
|
|
7816
|
+
billingAddress: {
|
|
7817
|
+
addressLine1: translatedBillingAddress.line1,
|
|
7818
|
+
addressLine2: translatedBillingAddress.line2 || '',
|
|
7819
|
+
city: translatedBillingAddress.city,
|
|
7820
|
+
country: translatedBillingAddress.country,
|
|
7821
|
+
postalCode: translatedBillingAddress.postal_code,
|
|
7822
|
+
state: translatedBillingAddress.state,
|
|
7823
|
+
},
|
|
7824
|
+
billingContact: {
|
|
7825
|
+
// firstName and lastName should be valid now since stripe only mark
|
|
7826
|
+
// the address as complete when both fields are filled.
|
|
7827
|
+
firstName: billingFirstName,
|
|
7828
|
+
lastName: billingLastName,
|
|
7829
|
+
phone: translatedBillingAddress.phone,
|
|
7830
|
+
},
|
|
7831
|
+
// Use the first item's currency code
|
|
7832
|
+
cartCurrencyCode: (_a = cartStore.items[0]) === null || _a === void 0 ? void 0 : _a.currencyCode,
|
|
7833
|
+
cartId,
|
|
7834
|
+
checkoutSessionId: cartStore.checkoutSessionId || '',
|
|
7835
|
+
contact: {
|
|
7836
|
+
email: stripeLinkData === null || stripeLinkData === void 0 ? void 0 : stripeLinkData.value.email,
|
|
7837
|
+
// firstName and lastName should be valid now since stripe only mark
|
|
7838
|
+
// the address as complete when both fields are filled.
|
|
7839
|
+
firstName: shippingFirstName,
|
|
7840
|
+
lastName: shippingLastName,
|
|
7841
|
+
phone: translatedShippingAddress.phone,
|
|
7842
|
+
},
|
|
7843
|
+
shippingAddress: {
|
|
7844
|
+
addressLine1: translatedShippingAddress.line1,
|
|
7845
|
+
addressLine2: translatedShippingAddress.line2,
|
|
7846
|
+
city: translatedShippingAddress.city,
|
|
7847
|
+
country: translatedShippingAddress.country,
|
|
7848
|
+
postalCode: translatedShippingAddress.postal_code,
|
|
7849
|
+
state: translatedShippingAddress.state,
|
|
7850
|
+
},
|
|
7851
|
+
};
|
|
7852
|
+
};
|
|
8043
7853
|
const prepCalculateLandedCost = () => {
|
|
8044
7854
|
// maybe we don't need email now for prefetch the landed cost
|
|
8045
7855
|
const stripeLinkData = stripeStore.stripeLinkEventData;
|
|
@@ -8109,13 +7919,13 @@ const triggerBuildLandedCost = async (buildLandedCost) => {
|
|
|
8109
7919
|
checkoutSessionId: data.checkoutSessionId,
|
|
8110
7920
|
contact: data.contact,
|
|
8111
7921
|
shippingAddress: data.shippingAddress,
|
|
8112
|
-
zonosApiRoute:
|
|
7922
|
+
zonosApiRoute: handleFetch.fallbackApiList['vercel'],
|
|
8113
7923
|
});
|
|
8114
7924
|
if (!landedCost || ((_a = landedCost.errors) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
8115
7925
|
throw new Error(`Failed to build landed cost: ${((_c = (_b = landedCost === null || landedCost === void 0 ? void 0 : landedCost.errors) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.message) || 'Unknown error'}`);
|
|
8116
7926
|
}
|
|
8117
7927
|
// Validate the landed cost object to make sure the returned value from buildLandedCost has a valid schema
|
|
8118
|
-
const { errors, json } = await handleFetch('/api/zonos-elements/validate-landed-cost', {
|
|
7928
|
+
const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/validate-landed-cost', {
|
|
8119
7929
|
body: landedCost,
|
|
8120
7930
|
headers: {
|
|
8121
7931
|
'Content-Type': 'application/json',
|
|
@@ -8137,7 +7947,7 @@ const calculateLandedCost = async (abortController) => {
|
|
|
8137
7947
|
return json;
|
|
8138
7948
|
}
|
|
8139
7949
|
// request to get landed cost info
|
|
8140
|
-
const { errors, json } = await handleFetch('/api/zonos-elements/calculate-landed-cost', {
|
|
7950
|
+
const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/calculate-landed-cost', {
|
|
8141
7951
|
body: prepCalculateLandedCost(),
|
|
8142
7952
|
method: 'POST',
|
|
8143
7953
|
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
|
|
@@ -8152,6 +7962,50 @@ const calculateLandedCost = async (abortController) => {
|
|
|
8152
7962
|
return json;
|
|
8153
7963
|
};
|
|
8154
7964
|
|
|
7965
|
+
const cartCalculateLandedCost = async ({ abortController, cartId, }) => {
|
|
7966
|
+
var _a;
|
|
7967
|
+
// request to get landed cost info
|
|
7968
|
+
const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/cart-calculate-landed-cost', {
|
|
7969
|
+
body: prepCartCalculateLandedCost(cartId),
|
|
7970
|
+
method: 'POST',
|
|
7971
|
+
signal: abortController === null || abortController === void 0 ? void 0 : abortController.signal,
|
|
7972
|
+
});
|
|
7973
|
+
if (errors.length || !json) {
|
|
7974
|
+
const isAbortedRequest = ((_a = errors[0]) === null || _a === void 0 ? void 0 : _a.message) === 'The user aborted a request.';
|
|
7975
|
+
const errorMessage = isAbortedRequest
|
|
7976
|
+
? 'The landed cost calculation request was aborted to initiate a new one.'
|
|
7977
|
+
: 'Failed to calculate landed cost';
|
|
7978
|
+
throw new Error(errorMessage);
|
|
7979
|
+
}
|
|
7980
|
+
return json;
|
|
7981
|
+
};
|
|
7982
|
+
|
|
7983
|
+
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
7984
|
+
var t = {};
|
|
7985
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
7986
|
+
t[p] = s[p];
|
|
7987
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7988
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7989
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
7990
|
+
t[p[i]] = s[p[i]];
|
|
7991
|
+
}
|
|
7992
|
+
return t;
|
|
7993
|
+
};
|
|
7994
|
+
const calculateLandedCostNormalized = async (abortController) => {
|
|
7995
|
+
const cartId = window.Zonos.cartId;
|
|
7996
|
+
// Calculate landed cost as usual if no cartId is available
|
|
7997
|
+
if (!cartId) {
|
|
7998
|
+
const landedCostResult = await calculateLandedCost(abortController);
|
|
7999
|
+
return landedCostResult;
|
|
8000
|
+
}
|
|
8001
|
+
// Calculate landed cost using cartId
|
|
8002
|
+
const _a = await cartCalculateLandedCost({
|
|
8003
|
+
abortController,
|
|
8004
|
+
cartId,
|
|
8005
|
+
}), { cartWorkflow } = _a, rest = __rest(_a, ["cartWorkflow"]);
|
|
8006
|
+
return Object.assign(Object.assign({}, rest), { itemCreateWorkflow: cartWorkflow.items });
|
|
8007
|
+
};
|
|
8008
|
+
|
|
8155
8009
|
/**
|
|
8156
8010
|
* This function generates an object that contains the fields of an address that have invalid characters.
|
|
8157
8011
|
*
|
|
@@ -8373,13 +8227,13 @@ const stripeStoreSaveDomesticShippingSession = (props) => {
|
|
|
8373
8227
|
};
|
|
8374
8228
|
const stripeStoreGetDomesticShippingSession = () => {
|
|
8375
8229
|
const session = window.sessionStorage.getItem('zonos--bigcommerce-domestic-checkout-shipping');
|
|
8376
|
-
return jsonParse(session);
|
|
8230
|
+
return handleFetch.jsonParse(session);
|
|
8377
8231
|
};
|
|
8378
8232
|
const initStripeElements = async (props) => {
|
|
8379
8233
|
var _a, _b;
|
|
8380
8234
|
const clientSecret = stripeStore.clientSecret;
|
|
8381
8235
|
if (!stripeStore.stripe) {
|
|
8382
|
-
|
|
8236
|
+
handleFetch.log('Skip. Stripe is not initialized');
|
|
8383
8237
|
return;
|
|
8384
8238
|
}
|
|
8385
8239
|
if (clientSecret) {
|
|
@@ -8399,11 +8253,11 @@ const initStripeElements = async (props) => {
|
|
|
8399
8253
|
stripeStore.stripeElements = (_a = stripeStore.stripe) === null || _a === void 0 ? void 0 : _a.elements(stripeOptions);
|
|
8400
8254
|
// save stripe elements options for later comparison
|
|
8401
8255
|
stripeStore.stripeElementsOptions = stripeOptions;
|
|
8402
|
-
|
|
8256
|
+
handleFetch.log('Stripe elements initialized');
|
|
8403
8257
|
// init stripe elements for billing address
|
|
8404
8258
|
stripeStore.stripeElementsForBillingAddress =
|
|
8405
8259
|
(_b = stripeStore.stripe) === null || _b === void 0 ? void 0 : _b.elements(stripeOptions);
|
|
8406
|
-
|
|
8260
|
+
handleFetch.log('Stripe elements for billing address initialized');
|
|
8407
8261
|
return;
|
|
8408
8262
|
}
|
|
8409
8263
|
if (!isSameOptions) {
|
|
@@ -8414,7 +8268,7 @@ const initStripeElements = async (props) => {
|
|
|
8414
8268
|
// save stripe elements options for later comparison
|
|
8415
8269
|
stripeStore.stripeElementsOptions = stripeOptions;
|
|
8416
8270
|
}
|
|
8417
|
-
|
|
8271
|
+
handleFetch.log('Stripe elements initialized');
|
|
8418
8272
|
}
|
|
8419
8273
|
};
|
|
8420
8274
|
const stripeStoreReset = () => {
|
|
@@ -8492,13 +8346,13 @@ const stripeStorePrefetchLandedCost = async () => {
|
|
|
8492
8346
|
stripeStore.fetchingLandedCostAbordController = abortController;
|
|
8493
8347
|
// Reset cart items to non-restricted state and restricted item list
|
|
8494
8348
|
cartStoreResetCartItems();
|
|
8495
|
-
const { checkoutSessionWorkflow, itemCreateWorkflow, landedCostCalculateWorkflow, shipmentRatingCalculateWorkflow, } = await
|
|
8349
|
+
const { checkoutSessionWorkflow, itemCreateWorkflow, landedCostCalculateWorkflow, shipmentRatingCalculateWorkflow, } = await calculateLandedCostNormalized(abortController);
|
|
8496
8350
|
// reset abort controller after we are done
|
|
8497
8351
|
stripeStore.fetchingLandedCostAbordController = null;
|
|
8498
8352
|
// update cart store with landed cost info
|
|
8499
8353
|
cartStore.landedCostData =
|
|
8500
8354
|
(checkoutSessionWorkflow === null || checkoutSessionWorkflow === void 0 ? void 0 : checkoutSessionWorkflow.map(checkoutSession => {
|
|
8501
|
-
const foundLandedCost = landedCostCalculateWorkflow === null || landedCostCalculateWorkflow === void 0 ? void 0 : landedCostCalculateWorkflow.find(item =>
|
|
8355
|
+
const foundLandedCost = landedCostCalculateWorkflow === null || landedCostCalculateWorkflow === void 0 ? void 0 : landedCostCalculateWorkflow.find(item => (item === null || item === void 0 ? void 0 : item.id) === checkoutSession.landedCostId);
|
|
8502
8356
|
if (!foundLandedCost) {
|
|
8503
8357
|
return null;
|
|
8504
8358
|
}
|
|
@@ -8516,6 +8370,7 @@ const stripeStorePrefetchLandedCost = async () => {
|
|
|
8516
8370
|
if (subtotals) {
|
|
8517
8371
|
// prefetch landed cost will not update shipping and taxes since we haven't selected shipping method yet
|
|
8518
8372
|
cartStoreApplySubtotals({
|
|
8373
|
+
adjustments: subtotals.adjustments,
|
|
8519
8374
|
exchangeRate: subtotals.exchangeRate,
|
|
8520
8375
|
items: subtotals.items,
|
|
8521
8376
|
landedCostTotal: 0,
|
|
@@ -8529,7 +8384,7 @@ const stripeStorePrefetchLandedCost = async () => {
|
|
|
8529
8384
|
// default to empty array if we fail to fetch landed cost, so we can show the error message
|
|
8530
8385
|
cartStore.landedCostData = [];
|
|
8531
8386
|
cartStore.shippingData = [];
|
|
8532
|
-
|
|
8387
|
+
handleFetch.logError(err);
|
|
8533
8388
|
}
|
|
8534
8389
|
stripeStore.isFetchingLandedCost = false;
|
|
8535
8390
|
}
|
|
@@ -8597,7 +8452,7 @@ const stripeStoreRetrievePayment = async ({ clientSecret: _clientSecret, storybo
|
|
|
8597
8452
|
}
|
|
8598
8453
|
const clientSecret = _clientSecret || stripeStore.clientSecret;
|
|
8599
8454
|
if (!stripeStore.stripe || !clientSecret) {
|
|
8600
|
-
|
|
8455
|
+
handleFetch.logError('Failed to retrieve payment intent. Stripe is not initialized');
|
|
8601
8456
|
return { error: true, message: [translate('Something went wrong.')] };
|
|
8602
8457
|
}
|
|
8603
8458
|
const { paymentIntent } = await stripeStore.stripe.retrievePaymentIntent(clientSecret);
|
|
@@ -8650,12 +8505,14 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
8650
8505
|
var _a;
|
|
8651
8506
|
const total = cartStore.items.reduce((amount, item) => amount + item.amount * item.quantity, 0);
|
|
8652
8507
|
if (!total || !localizationStore.targetCurrency) {
|
|
8653
|
-
|
|
8508
|
+
handleFetch.logError('Fail to create checkout session - invalid total or currency');
|
|
8654
8509
|
return false;
|
|
8655
8510
|
}
|
|
8656
8511
|
stripeStore.isFetchingSession = true;
|
|
8657
|
-
const { errors, json } = await handleFetch('/api/zonos-elements/create-checkout-session', {
|
|
8512
|
+
const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/create-checkout-session', {
|
|
8658
8513
|
body: {
|
|
8514
|
+
adjustmentAmount: cartStore.adjustments.reduce((prev, adj) => prev + adj.amount, 0),
|
|
8515
|
+
cartId: window.Zonos.cartId,
|
|
8659
8516
|
currency: ((_a = cartStore.items.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode) || '',
|
|
8660
8517
|
itemsAmount: total,
|
|
8661
8518
|
metadata: [{ key: 'language', value: localizationStore.selectedLocale }],
|
|
@@ -8665,7 +8522,7 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
8665
8522
|
});
|
|
8666
8523
|
stripeStore.isFetchingSession = false;
|
|
8667
8524
|
if (errors.length || !json) {
|
|
8668
|
-
|
|
8525
|
+
handleFetch.logError('Error occurs when creating checkout session', JSON.stringify(errors, null, 2));
|
|
8669
8526
|
return false;
|
|
8670
8527
|
}
|
|
8671
8528
|
const result = json.checkoutSessionCreate;
|
|
@@ -8673,18 +8530,20 @@ const stripeStoreInitCheckoutSession = async () => {
|
|
|
8673
8530
|
// update cart store with updated informations
|
|
8674
8531
|
cartStore.checkoutSessionId = result.id;
|
|
8675
8532
|
cartStoreApplySubtotals(Object.assign(Object.assign({}, result.subtotals), { landedCostTotal: 0, shipping: 0, total: result.subtotals.items }));
|
|
8676
|
-
|
|
8677
|
-
|
|
8533
|
+
handleFetch.log('Exchange rate updated for cart items (checkout session create)', 'info', cartStore.exchangeRate);
|
|
8534
|
+
handleFetch.log('done-init-checkout-session');
|
|
8678
8535
|
return true;
|
|
8679
8536
|
};
|
|
8680
8537
|
/**
|
|
8681
8538
|
* Update checkout session. Use for updating amount with landed cost id, or update session when cart items change
|
|
8682
8539
|
*/
|
|
8683
|
-
const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, landedCostId, presentmentCountryCode, }) => {
|
|
8540
|
+
const stripeStoreUpdateCheckoutSession = async ({ adjustmentAmount, cartId, currency, id, itemsAmount, landedCostId, presentmentCountryCode, }) => {
|
|
8684
8541
|
// No need to set loading state here because this function will be called under the hood to update
|
|
8685
8542
|
// landed cost id for the section.
|
|
8686
|
-
const { errors, json } = await handleFetch('/api/zonos-elements/update-checkout-session', {
|
|
8543
|
+
const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/update-checkout-session', {
|
|
8687
8544
|
body: {
|
|
8545
|
+
adjustmentAmount,
|
|
8546
|
+
cartId,
|
|
8688
8547
|
currency,
|
|
8689
8548
|
id,
|
|
8690
8549
|
itemsAmount,
|
|
@@ -8694,7 +8553,7 @@ const stripeStoreUpdateCheckoutSession = async ({ currency, id, itemsAmount, lan
|
|
|
8694
8553
|
method: 'POST',
|
|
8695
8554
|
});
|
|
8696
8555
|
if (errors.length || !json) {
|
|
8697
|
-
|
|
8556
|
+
handleFetch.logError('Error occurs when updating checkout session', JSON.stringify(errors, null, 2));
|
|
8698
8557
|
return { errors, json };
|
|
8699
8558
|
}
|
|
8700
8559
|
return { errors: [], json };
|
|
@@ -8782,12 +8641,12 @@ const stripeStoreTranslateAddressToLatin = async ({ addressInvalidCharactersList
|
|
|
8782
8641
|
if (!isAddressOutdated) {
|
|
8783
8642
|
return;
|
|
8784
8643
|
}
|
|
8785
|
-
const { errors, json } = await handleFetch('/api/zonos-elements/validate-address', {
|
|
8644
|
+
const { errors, json } = await handleFetch.handleFetch('/api/zonos-elements/validate-address', {
|
|
8786
8645
|
body: requestBody,
|
|
8787
8646
|
method: 'POST',
|
|
8788
8647
|
});
|
|
8789
8648
|
if (errors.length || !json) {
|
|
8790
|
-
|
|
8649
|
+
handleFetch.logError('Error occurs when translating address to latin', JSON.stringify(errors, null, 2));
|
|
8791
8650
|
// reset translated address if we fail to translate and let user manually fix it
|
|
8792
8651
|
stripeStore.translatedAddress = {
|
|
8793
8652
|
address: {},
|
|
@@ -8845,6 +8704,8 @@ const getDaysDifference = (targetDate) => {
|
|
|
8845
8704
|
};
|
|
8846
8705
|
|
|
8847
8706
|
const { onChange, reset, state: cartStore, } = zonosStore.createStore(() => ({
|
|
8707
|
+
adjustmentTotal: 0,
|
|
8708
|
+
adjustments: [],
|
|
8848
8709
|
checkoutSessionId: sessionStorage.getItem('zonos--checkout-session-id') || null,
|
|
8849
8710
|
checkoutSessionTimeoutShow: false,
|
|
8850
8711
|
checkoutTimeoutInterval: null,
|
|
@@ -8929,7 +8790,7 @@ const getMatchItem = ({ item1, item2, }) => {
|
|
|
8929
8790
|
* Check and set restricted items in cart
|
|
8930
8791
|
*/
|
|
8931
8792
|
const cartStoreCheckItemRestrictions = (itemsWorkflow) => {
|
|
8932
|
-
|
|
8793
|
+
handleFetch.log('Checking item restrictions');
|
|
8933
8794
|
const mappedRestrictedItems = itemsWorkflow
|
|
8934
8795
|
.map(item => {
|
|
8935
8796
|
if (!item.restriction) {
|
|
@@ -8965,6 +8826,7 @@ const cartStoreUpdateToErrorState = ({ messages, title, }) => {
|
|
|
8965
8826
|
const cartStoreApplySubtotals = (subtotals) => {
|
|
8966
8827
|
// update exchange rate so we can use it to display cart items
|
|
8967
8828
|
cartStore.exchangeRate = subtotals.exchangeRate;
|
|
8829
|
+
cartStore.adjustmentTotal = subtotals.adjustments;
|
|
8968
8830
|
cartStore.dutiesTaxFees = subtotals.landedCostTotal;
|
|
8969
8831
|
cartStore.subtotal = subtotals.items;
|
|
8970
8832
|
cartStore.total = subtotals.total;
|
|
@@ -8980,19 +8842,21 @@ const cartStoreHasOneEligibleItem = () => {
|
|
|
8980
8842
|
// if there is no item restricted found => all items are restricted
|
|
8981
8843
|
return !!checkItems.find(item => !item.isRestricted);
|
|
8982
8844
|
};
|
|
8983
|
-
const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId, }) => {
|
|
8845
|
+
const cartStoreReCalculateTotal = async ({ adjustmentAmount, cartId, currency, itemsAmount, landedCostId, }) => {
|
|
8984
8846
|
if (landedCostId && cartStore.selectedLandedCost) {
|
|
8985
8847
|
// update cart total right away if we have landed cost id to avoid order total flickering
|
|
8986
8848
|
const subtotals = cartStore.selectedLandedCost.subtotals;
|
|
8987
8849
|
cartStoreApplySubtotals(subtotals);
|
|
8988
|
-
|
|
8850
|
+
handleFetch.log('Exchange rate updated for cart items (landed cost subtotal)', 'info', cartStore.exchangeRate);
|
|
8989
8851
|
}
|
|
8990
8852
|
// update checkout session
|
|
8991
8853
|
if (!cartStore.checkoutSessionId) {
|
|
8992
|
-
|
|
8854
|
+
handleFetch.logError('Could not update cart total without checkout session id');
|
|
8993
8855
|
return false;
|
|
8994
8856
|
}
|
|
8995
8857
|
const { errors, json } = await stripeStoreUpdateCheckoutSession({
|
|
8858
|
+
adjustmentAmount,
|
|
8859
|
+
cartId,
|
|
8996
8860
|
currency,
|
|
8997
8861
|
id: cartStore.checkoutSessionId,
|
|
8998
8862
|
itemsAmount,
|
|
@@ -9001,7 +8865,7 @@ const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId,
|
|
|
9001
8865
|
});
|
|
9002
8866
|
if (errors.length > 0 || !json) {
|
|
9003
8867
|
// do nothing if we can't get checkout session
|
|
9004
|
-
|
|
8868
|
+
handleFetch.logError('Error occurs when updating checkout session');
|
|
9005
8869
|
cartStoreUpdateToErrorState({
|
|
9006
8870
|
messages: [
|
|
9007
8871
|
translate("There's been an error updating your checkout session. Please reload and try again or contact support if the error persists"),
|
|
@@ -9014,7 +8878,7 @@ const cartStoreReCalculateTotal = async ({ currency, itemsAmount, landedCostId,
|
|
|
9014
8878
|
// This is when first open the checkout modal and we just want to get info from the old cart session.
|
|
9015
8879
|
// use subtotals from checkout session to update cart total
|
|
9016
8880
|
cartStoreApplySubtotals(json.checkoutSessionUpdate.subtotals);
|
|
9017
|
-
|
|
8881
|
+
handleFetch.log('Exchange rate updated for cart items (checkout session update)', 'info', cartStore.exchangeRate);
|
|
9018
8882
|
}
|
|
9019
8883
|
return true;
|
|
9020
8884
|
};
|
|
@@ -9049,6 +8913,8 @@ const cartStoreUpdateSelectedShippingOption = async (selectedShippingOption) =>
|
|
|
9049
8913
|
cartStore.isSelectedShippingGuarantee = isGuarantee;
|
|
9050
8914
|
// update session with selected landed cost
|
|
9051
8915
|
const updateCalulateStatus = await cartStoreReCalculateTotal({
|
|
8916
|
+
adjustmentAmount: cartStore.adjustmentTotal,
|
|
8917
|
+
cartId: window.Zonos.cartId,
|
|
9052
8918
|
landedCostId: (_e = selectedLandedCost.landedCost) === null || _e === void 0 ? void 0 : _e.id,
|
|
9053
8919
|
});
|
|
9054
8920
|
return updateCalulateStatus;
|
|
@@ -9071,7 +8937,7 @@ const cartStoreStartCheckoutInterval = ({ isPreview, sessionTimeout, }) => {
|
|
|
9071
8937
|
timeoutQuery && !isNaN(parseInt(timeoutQuery, 10))
|
|
9072
8938
|
? parseInt(timeoutQuery, 10)
|
|
9073
8939
|
: sessionTimeout;
|
|
9074
|
-
|
|
8940
|
+
handleFetch.log(`==START CHECKOUT TIMEOUT - ${timeout}==`);
|
|
9075
8941
|
cartStore.checkoutTimeoutInterval = setTimeout(() => {
|
|
9076
8942
|
cartStore.checkoutSessionTimeoutShow = true;
|
|
9077
8943
|
}, timeout);
|
|
@@ -9088,13 +8954,16 @@ const cartStoreResetCartItems = () => {
|
|
|
9088
8954
|
cartStore.items = cartStore.items.map(item => (Object.assign(Object.assign({}, item), { isRestricted: false })));
|
|
9089
8955
|
cartStore.restrictedItems = [];
|
|
9090
8956
|
};
|
|
9091
|
-
const cartStoreUpdateItems = async (cartItems) => {
|
|
8957
|
+
const cartStoreUpdateItems = async ({ adjustments, cartItems, }) => {
|
|
9092
8958
|
var _a;
|
|
8959
|
+
// Update adjustments and items
|
|
8960
|
+
cartStore.adjustments = adjustments;
|
|
9093
8961
|
cartStore.items = getCartItemToUse(cartItems);
|
|
9094
8962
|
const currency = (_a = cartItems.find(Boolean)) === null || _a === void 0 ? void 0 : _a.currencyCode;
|
|
9095
8963
|
const total = cartItems.reduce((amt, item) => {
|
|
9096
8964
|
return amt + item.amount * item.quantity;
|
|
9097
8965
|
}, 0);
|
|
8966
|
+
const adjustmenTotal = adjustments.reduce((amt, adjustment) => amt + adjustment.amount, 0);
|
|
9098
8967
|
if (!currency || !total) {
|
|
9099
8968
|
// do nothing if we can't get currency or total
|
|
9100
8969
|
return;
|
|
@@ -9103,6 +8972,8 @@ const cartStoreUpdateItems = async (cartItems) => {
|
|
|
9103
8972
|
// set loading state here because this is first load checkout session when we already have checkout session id stored
|
|
9104
8973
|
stripeStore.isFetchingSession = true;
|
|
9105
8974
|
await cartStoreReCalculateTotal({
|
|
8975
|
+
adjustmentAmount: adjustmenTotal,
|
|
8976
|
+
cartId: window.Zonos.cartId,
|
|
9106
8977
|
currency: currency,
|
|
9107
8978
|
itemsAmount: total,
|
|
9108
8979
|
});
|
|
@@ -9156,16 +9027,13 @@ exports.currencyConvertAndFormat = currencyConvertAndFormat;
|
|
|
9156
9027
|
exports.currencyDisplay = currencyDisplay;
|
|
9157
9028
|
exports.currencyFormat = currencyFormat;
|
|
9158
9029
|
exports.getZCountryUrlParam = getZCountryUrlParam;
|
|
9159
|
-
exports.handleFetch = handleFetch;
|
|
9160
9030
|
exports.initLocalizationStore = initLocalizationStore;
|
|
9161
9031
|
exports.initStripeElements = initStripeElements;
|
|
9162
9032
|
exports.isValidSelector = isValidSelector;
|
|
9163
|
-
exports.jsonParse = jsonParse;
|
|
9164
9033
|
exports.localizationStore = localizationStore;
|
|
9165
9034
|
exports.localizationStoreOnUpdate = localizationStoreOnUpdate;
|
|
9166
9035
|
exports.localizationStoreUpdateSelectedCountryCode = localizationStoreUpdateSelectedCountryCode;
|
|
9167
9036
|
exports.localizationStoreUpdateSelectedLocale = localizationStoreUpdateSelectedLocale;
|
|
9168
|
-
exports.sendErrorLog = sendErrorLog;
|
|
9169
9037
|
exports.setZCountryUrlParam = setZCountryUrlParam;
|
|
9170
9038
|
exports.stripeStore = stripeStore;
|
|
9171
9039
|
exports.stripeStoreCleanupDomesticShippingSession = stripeStoreCleanupDomesticShippingSession;
|