@kachingappz/bundles-js 1.1.8 → 1.1.9
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/bundles-js.iife.js +39 -7
- package/dist/index.d.ts +19 -0
- package/dist/index.js +174 -92
- package/dist/kaching-bundle-component/index.d.ts +19 -0
- package/dist/kaching-bundle-component/index.js +203 -121
- package/dist/react/index.cjs +39 -7
- package/dist/react/index.d.ts +19 -0
- package/dist/react/index.js +193 -111
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -105,16 +105,16 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
105
105
|
return Array.from(new Set(i)).slice(0, c);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
}, p = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", m = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: c = !1,
|
|
108
|
+
}, p = "\n id\n availableForSale\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n selectedOptions {\n name\n value\n }\n image {\n id\n url(transform: $variantImageTransform)\n }\n unitPriceMeasurement {\n quantityUnit\n quantityValue\n referenceUnit\n referenceValue\n }\n requiresComponents\n sellingPlanAllocations(first: 100) @include(if: $includeSellingPlans) {\n nodes {\n sellingPlan {\n id\n }\n priceAdjustments {\n price {\n amount\n }\n compareAtPrice {\n amount\n }\n perDeliveryPrice {\n amount\n }\n }\n }\n }\n quantityAvailable @include(if: $includeAvailableQuantity)\n", m = async (e, { country: t, language: n, productIds: r, includeSellingPlans: i = !0, includeAvailableQuantity: a = !0, includeProductRating: o = !1, includeProductSubtitle: c = !1, includeProductTabFields: l = !1, productSubtitleMetafield: u = "descriptors.subtitle", useExternalMetafieldNamespace: d = !1, batchSize: f = 250, onBatchError: m, variantImageTransform: v = {
|
|
109
109
|
maxWidth: 200,
|
|
110
110
|
maxHeight: 200
|
|
111
111
|
} }) => {
|
|
112
112
|
if (!r.length) return [];
|
|
113
|
-
let
|
|
113
|
+
let y = r.map((e) => typeof e == "string" && e.startsWith("gid://") ? e : `gid://shopify/Product/${e}`), b = s({
|
|
114
114
|
country: t,
|
|
115
115
|
language: n
|
|
116
|
-
}),
|
|
117
|
-
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${
|
|
116
|
+
}), x = `
|
|
117
|
+
query FetchProducts($productGIDs: [ID!]!, $includeSellingPlans: Boolean!, $includeAvailableQuantity: Boolean!, $includeProductRating: Boolean!, $includeProductSubtitle: Boolean!, $includeProductTabFields: Boolean!, $subtitleNamespace: String!, $subtitleKey: String!, $metafieldNamespace: String!, $variantImageTransform: ImageTransformInput) ${b} {
|
|
118
118
|
shop {
|
|
119
119
|
currencyRateConstant: metafield(namespace: $metafieldNamespace, key: "currency_rate_constant") {
|
|
120
120
|
value
|
|
@@ -177,6 +177,10 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
177
177
|
subtitle: metafield(namespace: $subtitleNamespace, key: $subtitleKey) @include(if: $includeProductSubtitle) {
|
|
178
178
|
value
|
|
179
179
|
}
|
|
180
|
+
category @include(if: $includeProductTabFields) {
|
|
181
|
+
id
|
|
182
|
+
}
|
|
183
|
+
tags @include(if: $includeProductTabFields)
|
|
180
184
|
requiresSellingPlan
|
|
181
185
|
sellingPlanGroups(first: 100) @include(if: $includeSellingPlans) {
|
|
182
186
|
nodes {
|
|
@@ -184,6 +188,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
184
188
|
nodes {
|
|
185
189
|
id
|
|
186
190
|
name
|
|
191
|
+
recurringDeliveries
|
|
187
192
|
priceAdjustments {
|
|
188
193
|
adjustmentValue {
|
|
189
194
|
__typename
|
|
@@ -209,43 +214,63 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
209
214
|
}
|
|
210
215
|
}
|
|
211
216
|
}
|
|
212
|
-
`,
|
|
213
|
-
for (let e = 0; e <
|
|
214
|
-
let
|
|
215
|
-
let
|
|
216
|
-
productGIDs:
|
|
217
|
+
`, S = d ? "app--2935586817--kaching_bundles" : "$app:kaching_bundles", C = u.indexOf("."), w = u.slice(0, C), T = u.slice(C + 1), E = [], D = Math.min(f, 250);
|
|
218
|
+
for (let e = 0; e < y.length; e += D) E.push(y.slice(e, e + D));
|
|
219
|
+
let O = 1, k = async (n) => {
|
|
220
|
+
let [r, s] = await Promise.all([e.query(x, { variables: {
|
|
221
|
+
productGIDs: n,
|
|
217
222
|
includeSellingPlans: i,
|
|
218
223
|
includeAvailableQuantity: a,
|
|
219
224
|
includeProductRating: o,
|
|
220
225
|
includeProductSubtitle: c,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
226
|
+
includeProductTabFields: l,
|
|
227
|
+
subtitleNamespace: w,
|
|
228
|
+
subtitleKey: T,
|
|
229
|
+
metafieldNamespace: S,
|
|
230
|
+
variantImageTransform: v
|
|
231
|
+
} }), l ? h(e, t, n) : null]);
|
|
232
|
+
return r.shop.currencyRateConstant && (O = JSON.parse(r.shop.currencyRateConstant.value).amount / 1e6), s ? { nodes: r.nodes.map((e) => e && {
|
|
233
|
+
...e,
|
|
234
|
+
productType: s.get(e.id)
|
|
235
|
+
}) } : r;
|
|
236
|
+
}, A;
|
|
237
|
+
if (m) {
|
|
238
|
+
let e = await Promise.allSettled(E.map(k));
|
|
239
|
+
for (let t of e) t.status === "rejected" && m(t.reason instanceof Error ? t.reason : Error(String(t.reason)));
|
|
240
|
+
A = e.filter((e) => e.status === "fulfilled").flatMap((e) => e.value.nodes);
|
|
241
|
+
} else A = (await Promise.all(E.map(k))).flatMap((e) => e.nodes);
|
|
242
|
+
let j = A.filter((e) => e != null);
|
|
243
|
+
if (m) {
|
|
244
|
+
let t = await Promise.allSettled(j.map(async (t) => _(await g(e, t, {
|
|
236
245
|
includeSellingPlans: i,
|
|
237
246
|
includeAvailableQuantity: a,
|
|
238
|
-
variantImageTransform:
|
|
239
|
-
},
|
|
240
|
-
for (let e of t) e.status === "fulfilled" ? n.push(e.value) :
|
|
247
|
+
variantImageTransform: v
|
|
248
|
+
}, b), e.shopifyDomain, O))), n = [];
|
|
249
|
+
for (let e of t) e.status === "fulfilled" ? n.push(e.value) : m(e.reason instanceof Error ? e.reason : Error(String(e.reason)));
|
|
241
250
|
return n;
|
|
242
251
|
}
|
|
243
|
-
return (await Promise.all(
|
|
252
|
+
return (await Promise.all(j.map((t) => g(e, t, {
|
|
244
253
|
includeSellingPlans: i,
|
|
245
254
|
includeAvailableQuantity: a,
|
|
246
|
-
variantImageTransform:
|
|
247
|
-
},
|
|
248
|
-
}, h = async (e, t, n
|
|
255
|
+
variantImageTransform: v
|
|
256
|
+
}, b)))).map((t) => _(t, e.shopifyDomain, O));
|
|
257
|
+
}, h = async (e, t, n) => {
|
|
258
|
+
try {
|
|
259
|
+
let r = await e.query(`
|
|
260
|
+
query FetchProductTypes($productGIDs: [ID!]!) ${s({ country: t })} {
|
|
261
|
+
nodes(ids: $productGIDs) {
|
|
262
|
+
... on Product {
|
|
263
|
+
id
|
|
264
|
+
productType
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
`, { variables: { productGIDs: n } });
|
|
269
|
+
return new Map(r.nodes.filter((e) => e != null).map((e) => [e.id, e.productType]));
|
|
270
|
+
} catch (e) {
|
|
271
|
+
return console.error(e), null;
|
|
272
|
+
}
|
|
273
|
+
}, g = async (e, t, n, r = "") => {
|
|
249
274
|
if (t.variants.nodes.length < 250) return t;
|
|
250
275
|
let i = /* @__PURE__ */ new Set(), a = [], o = [], s = async (s) => {
|
|
251
276
|
let c = !0, l = null;
|
|
@@ -281,7 +306,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
281
306
|
}
|
|
282
307
|
};
|
|
283
308
|
return await Promise.all([s(!1), s(!0)]), t.variants.nodes = [...a, ...o.reverse()], t;
|
|
284
|
-
},
|
|
309
|
+
}, _ = (e, t, n) => {
|
|
285
310
|
let r = e.variants.nodes.map(({ unitPriceMeasurement: e, ...t }) => ({
|
|
286
311
|
id: Number(t.id.split("/").pop()),
|
|
287
312
|
availableForSale: t.availableForSale,
|
|
@@ -319,7 +344,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
319
344
|
defaultName: e.name,
|
|
320
345
|
name: e.name,
|
|
321
346
|
position: t + 1,
|
|
322
|
-
optionValues:
|
|
347
|
+
optionValues: b(n, t, r)
|
|
323
348
|
};
|
|
324
349
|
}), a = (e) => {
|
|
325
350
|
let t = e.priceAdjustments[0];
|
|
@@ -343,6 +368,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
343
368
|
}, o = (e) => n === 1 ? Number(e) * 100 : Math.round(Number(e) * 100 * n), s = e.sellingPlanGroups?.nodes.flatMap((e) => e.sellingPlans.nodes.map((e) => ({
|
|
344
369
|
id: Number(e.id.split("/").pop()),
|
|
345
370
|
name: e.name,
|
|
371
|
+
recurringDeliveries: e.recurringDeliveries,
|
|
346
372
|
priceAdjustment: a(e)
|
|
347
373
|
}))) || [], c = e.variants.nodes.some((e) => e.requiresComponents);
|
|
348
374
|
return {
|
|
@@ -366,27 +392,45 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
366
392
|
text3: e.metafield3?.value || null,
|
|
367
393
|
text4: e.metafield4?.value || null
|
|
368
394
|
},
|
|
369
|
-
rating:
|
|
370
|
-
subtitle: e.subtitle?.value || null
|
|
395
|
+
rating: v(e.reviewsRating, e.reviewsRatingCount),
|
|
396
|
+
subtitle: e.subtitle?.value || null,
|
|
397
|
+
productType: e.productType || null,
|
|
398
|
+
categoryGid: e.category?.id ?? null,
|
|
399
|
+
tags: e.tags ?? []
|
|
371
400
|
};
|
|
372
|
-
},
|
|
401
|
+
}, v = (e, t) => {
|
|
373
402
|
if (!e) return null;
|
|
374
|
-
let n =
|
|
403
|
+
let n = y(e.value);
|
|
375
404
|
if (n === null) return null;
|
|
376
405
|
let r = Number(t?.value);
|
|
377
406
|
return {
|
|
378
407
|
value: n,
|
|
379
408
|
count: Number.isInteger(r) && r > 0 ? r : null
|
|
380
409
|
};
|
|
381
|
-
},
|
|
410
|
+
}, y = (e) => {
|
|
382
411
|
try {
|
|
383
412
|
let { value: t, scale_max: n } = JSON.parse(e), r = Number(t) / Number(n) * 5;
|
|
384
413
|
return Number.isFinite(r) && r > 0 ? Math.min(5, r) : null;
|
|
385
414
|
} catch {
|
|
386
415
|
return null;
|
|
387
416
|
}
|
|
388
|
-
},
|
|
389
|
-
|
|
417
|
+
}, b = (e, t, n) => e.filter((e) => n.filter((n) => n.options[t] === e.name).length > 0);
|
|
418
|
+
[
|
|
419
|
+
"primaryBackground",
|
|
420
|
+
"secondaryBackground",
|
|
421
|
+
"primaryText",
|
|
422
|
+
"secondaryText",
|
|
423
|
+
"border",
|
|
424
|
+
"overlay",
|
|
425
|
+
"primaryAccent",
|
|
426
|
+
"primaryAccentText",
|
|
427
|
+
"badgeBackground",
|
|
428
|
+
"badgeText",
|
|
429
|
+
"error"
|
|
430
|
+
].map((e) => `brand_${e}`);
|
|
431
|
+
// ../bundles-storefront-api/dist/fetchGlobalConfig.js
|
|
432
|
+
var x = "app--2935586817", S = async (t, { language: n, country: r, useExternalMetafieldNamespace: i }) => {
|
|
433
|
+
let a = i ? `${x}--kaching_bundles` : "$app:kaching_bundles", o = i ? x : "$app", c = s({ country: r }), { localization: { country: { currency: { isoCode: l } } }, shop: { moneyFormat: u, paymentSettings: { currencyCode: d }, currencyRateConstant: f, primaryDomain: p, settingsMetafield: m } } = await t.query(`
|
|
390
434
|
query config($metafieldNamespace: String!, $settingsNamespace: String!) ${c} {
|
|
391
435
|
localization {
|
|
392
436
|
country {
|
|
@@ -417,7 +461,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
417
461
|
} }), h = l === d ? u : e(l, {
|
|
418
462
|
language: n,
|
|
419
463
|
country: r
|
|
420
|
-
}), g = f ?
|
|
464
|
+
}), g = f ? C(f.value) : 1, _ = m ? JSON.parse(m.value) : null, v = _?.feature_flags ?? {}, y = _?.custom_selectors ?? {};
|
|
421
465
|
return {
|
|
422
466
|
shopifyDomain: p.host,
|
|
423
467
|
moneyFormat: h,
|
|
@@ -478,7 +522,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
478
522
|
featureFlags: v,
|
|
479
523
|
brandColors: _?.brand_colors ?? null
|
|
480
524
|
};
|
|
481
|
-
},
|
|
525
|
+
}, C = (e) => JSON.parse(e).amount / 1e6, w = async (e, t, n = 200) => {
|
|
482
526
|
let r = [...new Set(t.filter(Boolean).filter((e) => !e.startsWith("placeholder")))];
|
|
483
527
|
if (r.length === 0) return [];
|
|
484
528
|
let i = [];
|
|
@@ -490,10 +534,33 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
490
534
|
gid: e.id,
|
|
491
535
|
url: e.image.url
|
|
492
536
|
}] : []);
|
|
493
|
-
},
|
|
494
|
-
...
|
|
495
|
-
|
|
496
|
-
|
|
537
|
+
}, T = 100, E = async (e, { dealBlock: t, country: n, language: r }) => {
|
|
538
|
+
let i = [...new Set(t.dealBars.flatMap((e) => e.dealBarType === d.MixAndMatch ? e.bundleProducts : []).flatMap((e) => (e.selectedCollections ?? []).map((e) => e.id)))];
|
|
539
|
+
if (i.length === 0) return [];
|
|
540
|
+
let a = s({
|
|
541
|
+
country: n,
|
|
542
|
+
language: r
|
|
543
|
+
}), o = await e.query(`
|
|
544
|
+
query FetchMixAndMatchCollectionProductGIDs($collectionGIDs: [ID!]!) ${a} {
|
|
545
|
+
nodes(ids: $collectionGIDs) {
|
|
546
|
+
... on Collection {
|
|
547
|
+
id
|
|
548
|
+
products(first: ${T}) {
|
|
549
|
+
nodes {
|
|
550
|
+
id
|
|
551
|
+
variants(first: 1) {
|
|
552
|
+
nodes {
|
|
553
|
+
requiresComponents
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
`, { variables: { collectionGIDs: i } });
|
|
562
|
+
return [...new Set(o.nodes.filter((e) => e !== null).flatMap((e) => e.products.nodes).filter((e) => !e.variants.nodes.some((e) => e.requiresComponents)).map((e) => e.id))];
|
|
563
|
+
}, D = (e) => [
|
|
497
564
|
...O(e),
|
|
498
565
|
...k(e),
|
|
499
566
|
...A(e),
|
|
@@ -503,64 +570,67 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
503
570
|
...P(e),
|
|
504
571
|
...F(e),
|
|
505
572
|
...I(e),
|
|
506
|
-
...L(e)
|
|
507
|
-
|
|
573
|
+
...L(e),
|
|
574
|
+
...R(e),
|
|
575
|
+
...z(e),
|
|
576
|
+
...B(e)
|
|
577
|
+
].filter((e) => e != null && !e.includes("placeholder")), O = (e) => e.dealBars.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), k = (e) => e.dealBars.flatMap((e) => e.dealBarType === d.Bundle ? e.bundleProducts.map((e) => e.mediaImageGID) : []).filter((e) => e != null), A = (e) => e.dealBars.map(({ freeGifts: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), j = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => (e || []).map((e) => e.mediaImageGID)).filter((e) => e != null), M = (e) => e.dealBars.map(({ upsells: e }) => (e || []).map((e) => e.mediaImageGID)).reduce((e, t) => e.concat(t), []).filter((e) => e != null), N = (e) => e.swatchOptions ? e.swatchOptions.reduce((e, t) => {
|
|
508
578
|
let n = t.images.map((e) => e.mediaImageGID).filter((e) => e != null);
|
|
509
579
|
return [...e, ...n];
|
|
510
|
-
}, []) : [],
|
|
580
|
+
}, []) : [], P = (e) => {
|
|
511
581
|
if (!e.collectionBreaksEnabled || !e.collectionBreaks) return [];
|
|
512
582
|
let t = e.collectionBreaks.mediaImageGID;
|
|
513
583
|
return t ? [t] : [];
|
|
514
|
-
},
|
|
584
|
+
}, F = (e) => e.progressiveGifts ? [
|
|
515
585
|
...e.progressiveGifts.gifts?.map((e) => e.mediaImageGID) || [],
|
|
516
586
|
e.progressiveGifts.style?.lockedMediaImageGID,
|
|
517
587
|
e.progressiveGifts.dealBarStyle?.lockedMediaImageGID
|
|
518
|
-
].filter((e) => e != null) : [],
|
|
588
|
+
].filter((e) => e != null) : [], I = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.flatMap((e) => [e.mediaImageGID, e.badgeImageGID]).filter((e) => e != null), L = (e) => e.dealBars.map((e) => e.productPersonalisation?.mediaImageGID).filter((e) => e != null), R = (e) => {
|
|
519
589
|
let t = e.dealBars.map((e) => e.highlights?.customIconGID).filter((e) => e != null), n = e.subscriptions?.highlights?.customIconGID;
|
|
520
590
|
return n ? [...t, n] : t;
|
|
521
|
-
},
|
|
522
|
-
let
|
|
523
|
-
...z(e),
|
|
524
|
-
...B(e),
|
|
525
|
-
...V(e),
|
|
591
|
+
}, z = (e) => (e.badges || []).flatMap((e) => e.badgeType === "custom" && e.imageGID ? [e.imageGID] : []), B = (e) => !e.savingsSummaryEnabled || !e.savingsSummary ? [] : e.savingsSummary.customIconGID ? [e.savingsSummary.customIconGID] : [], V = (e, { includeMixAndMatchSwapProducts: t = !0 } = {}) => {
|
|
592
|
+
let n = [
|
|
526
593
|
...H(e),
|
|
527
594
|
...U(e),
|
|
528
595
|
...W(e),
|
|
529
596
|
...G(e),
|
|
530
|
-
...K(e)
|
|
597
|
+
...K(e),
|
|
598
|
+
...q(e, t),
|
|
599
|
+
...J(e),
|
|
600
|
+
...Y(e)
|
|
531
601
|
];
|
|
532
|
-
return Array.from(new Set(
|
|
533
|
-
},
|
|
602
|
+
return Array.from(new Set(n.filter((e) => e != null)));
|
|
603
|
+
}, H = (e) => e.dealBars.flatMap(({ freeGifts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), U = (e) => e.dealBars.flatMap(({ multipleGiftsSelectors: e }) => e ? e.flatMap((e) => e.products ? e.products.map((e) => e.id) : []) : []).filter((e) => e != null), W = (e) => e.progressiveGiftsEnabled && e.progressiveGifts?.gifts.map((e) => e.productGID).filter((e) => e != null) || [], G = (e) => e.dealBars.flatMap(({ upsells: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null), K = (e) => e.dealBars.filter((e) => e.dealBarType === d.Bundle).flatMap(({ bundleProducts: e }) => e ? e.map((e) => e.productGID) : []).filter((e) => e != null).filter((e) => e !== "default"), q = (e, t) => e.dealBars.filter((e) => e.dealBarType === d.MixAndMatch).flatMap(({ bundleProducts: e }) => e ? e.flatMap((e) => [e.productGID, ...t ? e.selectedProducts?.map((e) => e.id) ?? [] : []]) : []).filter((e) => e != null).filter((e) => e !== "default"), J = (e) => !e.checkboxUpsellsEnabled || !e.checkboxUpsells ? [] : e.checkboxUpsells.upsells.map((e) => e.productGID).filter((e) => e != null), Y = (e) => e.dealBars.filter((e) => e.dealBarType === d.Sku).flatMap(({ productGID: e }) => e ? [e] : []), X = class extends Error {
|
|
534
604
|
constructor({ status: e, operationName: t, graphqlErrors: n }) {
|
|
535
605
|
let r = n.length ? `: ${n.join("; ")}` : "";
|
|
536
606
|
super(`Storefront API ${t ?? "query"} failed (HTTP ${e})${r}`), this.name = "StorefrontApiError", this.status = e, this.operationName = t, this.graphqlErrors = n;
|
|
537
607
|
}
|
|
538
|
-
},
|
|
608
|
+
}, Z = async (e, t) => {
|
|
539
609
|
let n = await e.text();
|
|
540
610
|
if (!n) throw Error("Empty graphql response");
|
|
541
611
|
let r;
|
|
542
612
|
try {
|
|
543
613
|
r = JSON.parse(n);
|
|
544
614
|
} catch (n) {
|
|
545
|
-
throw e.ok ? n : new
|
|
615
|
+
throw e.ok ? n : new X({
|
|
546
616
|
status: e.status,
|
|
547
617
|
operationName: t,
|
|
548
618
|
graphqlErrors: []
|
|
549
619
|
});
|
|
550
620
|
}
|
|
551
|
-
if (!e.ok || r.data === null || r.data === void 0) throw new
|
|
621
|
+
if (!e.ok || r.data === null || r.data === void 0) throw new X({
|
|
552
622
|
status: e.status,
|
|
553
623
|
operationName: t,
|
|
554
624
|
graphqlErrors: (r.errors ?? []).map(({ message: e }) => e).filter(Boolean)
|
|
555
625
|
});
|
|
556
626
|
return r.data;
|
|
557
|
-
},
|
|
627
|
+
}, ee = class {
|
|
558
628
|
constructor(e, t) {
|
|
559
629
|
this.storefrontApiVersion = "2026-07", this.storefrontAccessToken = t, this.shopifyDomain = e;
|
|
560
630
|
}
|
|
561
631
|
async query(e, t) {
|
|
562
632
|
let n = t?.variables ?? {}, r = `https://${this.shopifyDomain}/api/${this.storefrontApiVersion}/graphql.json`, i = e.match(/query\s+(\w+)/)?.[1];
|
|
563
|
-
return i && (r += `?operation_name=${i}`),
|
|
633
|
+
return i && (r += `?operation_name=${i}`), Z(await fetch(r, {
|
|
564
634
|
method: "POST",
|
|
565
635
|
headers: {
|
|
566
636
|
"Content-Type": "application/json",
|
|
@@ -572,7 +642,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
572
642
|
})
|
|
573
643
|
}), i);
|
|
574
644
|
}
|
|
575
|
-
},
|
|
645
|
+
}, Q = (e, t) => {
|
|
576
646
|
let n = [], r = e.filter((e) => e.blockVisibility === "selected-products");
|
|
577
647
|
for (let e of r) e.selectedProductIds.map(Number).includes(t.id) && n.push(e);
|
|
578
648
|
let i = e.filter((e) => e.blockVisibility === "selected-collections");
|
|
@@ -582,7 +652,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
582
652
|
let o = e.filter((e) => e.blockVisibility === "all-products");
|
|
583
653
|
for (let e of o) n.push(e);
|
|
584
654
|
return n;
|
|
585
|
-
},
|
|
655
|
+
}, te = async (e, t, { country: n, language: r }) => {
|
|
586
656
|
let i = t.collectionBreaks;
|
|
587
657
|
if (!t.collectionBreaksEnabled || !i) return;
|
|
588
658
|
let a;
|
|
@@ -607,8 +677,8 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
607
677
|
productIds: a.map((e) => Number(e.split("/").pop())),
|
|
608
678
|
useExternalMetafieldNamespace: !0
|
|
609
679
|
}), s = i.visibility === "deal-products" && t.blockVisibility === "excluded-products";
|
|
610
|
-
return o = o.filter((e) => e.availableForSale && (!s ||
|
|
611
|
-
},
|
|
680
|
+
return o = o.filter((e) => e.availableForSale && (!s || Q([t], e).length > 0)), o;
|
|
681
|
+
}, ne = ({ language: e, dealBlockId: t }) => {
|
|
612
682
|
let n = {
|
|
613
683
|
"system.out_of_stock": "There's not enough items in our stock, please select smaller bundle.",
|
|
614
684
|
"system.invalid_variant": "Sorry, this is not currently available.",
|
|
@@ -635,13 +705,13 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
635
705
|
"system.numbers_only": "Only numbers are allowed.",
|
|
636
706
|
"system.personalisation_required_alert": "Please add personalisation for every item to continue.",
|
|
637
707
|
"system.gifts_required_alert": "Please choose your free gifts"
|
|
638
|
-
}, r = e ?
|
|
708
|
+
}, r = e ? re(e) : void 0;
|
|
639
709
|
return {
|
|
640
710
|
...n,
|
|
641
711
|
...r?.system,
|
|
642
712
|
...r?.dealBlocks[t]
|
|
643
713
|
};
|
|
644
|
-
},
|
|
714
|
+
}, re = (e) => {
|
|
645
715
|
if (typeof document > "u") return;
|
|
646
716
|
let t = document.querySelector("script#kaching-bundles-translations");
|
|
647
717
|
if (!t?.textContent) return;
|
|
@@ -653,17 +723,17 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
653
723
|
}
|
|
654
724
|
let r = $(e);
|
|
655
725
|
return n.find((e) => $(e.locale) === r)?.translations;
|
|
656
|
-
}, $ = (e) => e.toLowerCase().replace(/_/g, "-"),
|
|
726
|
+
}, $ = (e) => e.toLowerCase().replace(/_/g, "-"), ie = "2026-07", ae = async (e, { productId: t, dealBlockId: n, abTestVariantId: r, country: i = void 0, language: a = void 0 }) => {
|
|
657
727
|
try {
|
|
658
|
-
let o = [Number(t.split("/").pop())], s = new
|
|
728
|
+
let o = [Number(t.split("/").pop())], s = new oe(e);
|
|
659
729
|
i ||= s.i18n?.country, a ||= s.i18n?.language;
|
|
660
|
-
let l = await
|
|
730
|
+
let l = await S(s, {
|
|
661
731
|
language: a,
|
|
662
732
|
country: i,
|
|
663
733
|
useExternalMetafieldNamespace: !0
|
|
664
734
|
});
|
|
665
735
|
s.shopifyDomain = l.shopifyDomain;
|
|
666
|
-
let u = l.storefrontAccessToken ? new
|
|
736
|
+
let u = l.storefrontAccessToken ? new ee(l.shopifyDomain, l.storefrontAccessToken) : s, [d, f] = await Promise.all([m(u, {
|
|
667
737
|
country: i,
|
|
668
738
|
language: a,
|
|
669
739
|
productIds: o,
|
|
@@ -673,21 +743,33 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
673
743
|
useMetaobjects: l.featureFlags.storefront_metaobjects
|
|
674
744
|
})]), p = d[0];
|
|
675
745
|
if (!p) return null;
|
|
676
|
-
let h =
|
|
746
|
+
let h = Q(f, p), g = n ? h.filter((e) => e.id === n || e.nanoId === n) : h, _ = (r ? g.find((e) => e.abTestVariantId === r) : void 0) ?? g[0] ?? h[0];
|
|
677
747
|
if (!_) return null;
|
|
678
|
-
let v =
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
748
|
+
let v = D(_), [y, b, x, C] = await Promise.all([
|
|
749
|
+
(async () => {
|
|
750
|
+
let e = [];
|
|
751
|
+
try {
|
|
752
|
+
e = await E(u, {
|
|
753
|
+
dealBlock: _,
|
|
754
|
+
country: i,
|
|
755
|
+
language: a
|
|
756
|
+
});
|
|
757
|
+
} catch (e) {
|
|
758
|
+
console.error(e);
|
|
759
|
+
}
|
|
760
|
+
return m(u, {
|
|
761
|
+
country: i,
|
|
762
|
+
language: a,
|
|
763
|
+
productIds: [.../* @__PURE__ */ new Set([...V(_), ...e])],
|
|
764
|
+
useExternalMetafieldNamespace: !0
|
|
765
|
+
});
|
|
766
|
+
})(),
|
|
767
|
+
w(u, v, 300),
|
|
768
|
+
te(u, _, {
|
|
687
769
|
country: i,
|
|
688
770
|
language: a
|
|
689
771
|
}),
|
|
690
|
-
|
|
772
|
+
ne({
|
|
691
773
|
language: a,
|
|
692
774
|
dealBlockId: _.id
|
|
693
775
|
})
|
|
@@ -696,15 +778,15 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
696
778
|
product: p,
|
|
697
779
|
dealBlock: _,
|
|
698
780
|
config: l,
|
|
699
|
-
otherProducts:
|
|
700
|
-
mediaImages:
|
|
701
|
-
collectionBreaksProducts:
|
|
702
|
-
translations:
|
|
781
|
+
otherProducts: y,
|
|
782
|
+
mediaImages: b,
|
|
783
|
+
collectionBreaksProducts: x ?? [],
|
|
784
|
+
translations: C
|
|
703
785
|
};
|
|
704
786
|
} catch (e) {
|
|
705
787
|
return console.error(e), null;
|
|
706
788
|
}
|
|
707
|
-
},
|
|
789
|
+
}, oe = class {
|
|
708
790
|
constructor(e) {
|
|
709
791
|
this.storefront = e, this.shopifyDomain = "";
|
|
710
792
|
}
|
|
@@ -717,7 +799,7 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
717
799
|
}
|
|
718
800
|
if ("request" in this.storefront) return (await this.storefront.request(e, t)).data;
|
|
719
801
|
if ("shopifyDomain" in this.storefront && "storefrontAccessToken" in this.storefront) {
|
|
720
|
-
let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${
|
|
802
|
+
let n = await fetch(`https://${this.storefront.shopifyDomain}/api/${ie}/graphql.json`, {
|
|
721
803
|
body: JSON.stringify({
|
|
722
804
|
query: e,
|
|
723
805
|
variables: t?.variables
|
|
@@ -748,4 +830,4 @@ var d = /* @__PURE__ */ function(e) {
|
|
|
748
830
|
if ("i18n" in this.storefront) return this.storefront.i18n;
|
|
749
831
|
}
|
|
750
832
|
};
|
|
751
|
-
export {
|
|
833
|
+
export { ae as fetchKachingBundlesData };
|
|
@@ -315,6 +315,7 @@ declare type DealBlock = {
|
|
|
315
315
|
showTotalPriceInAddToCartButton?: boolean;
|
|
316
316
|
includeUpsellsInDealBarPrice?: boolean;
|
|
317
317
|
skipCart: boolean;
|
|
318
|
+
skipCartRemoveOtherProducts?: boolean;
|
|
318
319
|
showVariantsForSingleQuantity: boolean;
|
|
319
320
|
preselectedDealBarId: string | null;
|
|
320
321
|
cornerRadius: number;
|
|
@@ -578,6 +579,15 @@ declare interface GlobalConfig {
|
|
|
578
579
|
"system.deal_page_default_empty_note"?: string;
|
|
579
580
|
"system.deal_page_default_add_to_box"?: string;
|
|
580
581
|
"system.deal_page_default_add_box_to_cart"?: string;
|
|
582
|
+
"system.deal_page_default_subscribe_title"?: string;
|
|
583
|
+
"system.deal_page_default_subscribe_subtitle"?: string;
|
|
584
|
+
"system.deal_page_default_one_time_title"?: string;
|
|
585
|
+
"system.deal_page_purchase_options"?: string;
|
|
586
|
+
"system.deal_page_frequency"?: string;
|
|
587
|
+
"system.deal_page_one_time_only"?: string;
|
|
588
|
+
"system.deal_page_subscription_only"?: string;
|
|
589
|
+
"system.deal_page_some_items_subscription_only"?: string;
|
|
590
|
+
"system.deal_page_remove_subscription_only_items"?: string;
|
|
581
591
|
"system.deal_page_items_range"?: string;
|
|
582
592
|
"system.deal_page_tip_box_size"?: string;
|
|
583
593
|
"system.deal_page_about_this_price"?: string;
|
|
@@ -648,6 +658,7 @@ declare interface GlobalConfig {
|
|
|
648
658
|
intercept_cart_request?: boolean;
|
|
649
659
|
klaviyo_integration?: boolean;
|
|
650
660
|
legacy_saved_percentage?: boolean;
|
|
661
|
+
localized_most_popular_badge?: boolean;
|
|
651
662
|
low_priority_scripts?: boolean;
|
|
652
663
|
native_swatches_disabled?: boolean;
|
|
653
664
|
observe_external_selling_plan?: boolean;
|
|
@@ -669,6 +680,7 @@ declare interface GlobalConfig {
|
|
|
669
680
|
widget_scroll_guard?: boolean;
|
|
670
681
|
};
|
|
671
682
|
shopCustomStyles: string;
|
|
683
|
+
shopDealPageCustomStyles?: string;
|
|
672
684
|
brandColors?: BrandColors | null;
|
|
673
685
|
}
|
|
674
686
|
|
|
@@ -763,6 +775,9 @@ declare interface MixAndMatchProduct {
|
|
|
763
775
|
id: string;
|
|
764
776
|
variantGIDs: string[] | null;
|
|
765
777
|
}[];
|
|
778
|
+
selectedCollections?: {
|
|
779
|
+
id: string;
|
|
780
|
+
}[];
|
|
766
781
|
}
|
|
767
782
|
|
|
768
783
|
declare type MostPopularBadge = BaseBadge & {
|
|
@@ -814,6 +829,9 @@ declare interface Product {
|
|
|
814
829
|
};
|
|
815
830
|
rating?: ProductRating | null;
|
|
816
831
|
subtitle?: string | null;
|
|
832
|
+
productType?: string | null;
|
|
833
|
+
categoryGid?: string | null;
|
|
834
|
+
tags?: string[];
|
|
817
835
|
}
|
|
818
836
|
|
|
819
837
|
declare interface ProductOption {
|
|
@@ -958,6 +976,7 @@ declare type ScratchOff = {
|
|
|
958
976
|
declare interface SellingPlan {
|
|
959
977
|
id: number;
|
|
960
978
|
name: string;
|
|
979
|
+
recurringDeliveries?: boolean;
|
|
961
980
|
priceAdjustment: {
|
|
962
981
|
type: "percentage" | "fixed_amount" | "price";
|
|
963
982
|
value: number;
|