@lime-bundles/widget 4.6.2 → 4.6.4
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/index.cjs +57 -43
- package/dist/index.js +33 -18
- package/dist/lime-bundle.global.js +5 -5
- package/dist/lime-bundle.global.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -26,7 +26,7 @@ __export(index_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
28
|
// src/lime-bundle.ts
|
|
29
|
-
var
|
|
29
|
+
var import_core7 = require("@lime-bundles/core");
|
|
30
30
|
|
|
31
31
|
// ../render/src/host.ts
|
|
32
32
|
function intlFormatMoney(currencyCode) {
|
|
@@ -537,11 +537,13 @@ function buildWidgetShell(typeClass, opts) {
|
|
|
537
537
|
const countdown = box("div", "lb-bundle-countdown", {
|
|
538
538
|
"data-countdown": ""
|
|
539
539
|
});
|
|
540
|
-
const label2 = box("
|
|
541
|
-
|
|
540
|
+
const label2 = box("div", "lb-bundle-countdown__label");
|
|
541
|
+
const labelText = document.createElement("span");
|
|
542
|
+
labelText.textContent = opts.countdownLabel ?? "Limited time offer";
|
|
543
|
+
label2.appendChild(labelText);
|
|
542
544
|
countdown.appendChild(label2);
|
|
543
545
|
countdown.appendChild(
|
|
544
|
-
box("span", "lb-bundle-
|
|
546
|
+
box("span", "lb-bundle-countdown__timer", {
|
|
545
547
|
"data-countdown-timer": ""
|
|
546
548
|
})
|
|
547
549
|
);
|
|
@@ -761,7 +763,7 @@ var DEFAULT_STRINGS = {
|
|
|
761
763
|
allTypes: "All",
|
|
762
764
|
editSelection: "Edit selection",
|
|
763
765
|
addToCart: "Add to cart",
|
|
764
|
-
bundlePrice: "Bundle
|
|
766
|
+
bundlePrice: "Bundle total",
|
|
765
767
|
save: "Save",
|
|
766
768
|
complete: "Complete",
|
|
767
769
|
ofSelected: "__COUNT__ of __TOTAL__ added",
|
|
@@ -2297,6 +2299,7 @@ function buildSlotCard(item, trans, formatMoney, removable, onRemove, onEdit) {
|
|
|
2297
2299
|
}
|
|
2298
2300
|
|
|
2299
2301
|
// ../render/src/mix-match/slots.ts
|
|
2302
|
+
var import_core3 = require("@lime-bundles/core");
|
|
2300
2303
|
function updateSlotUI(cont, items, reqQty, d, deps) {
|
|
2301
2304
|
const trans = d.translations || {};
|
|
2302
2305
|
const slotsWrap = cont.querySelector("[data-selection-slots]");
|
|
@@ -2329,7 +2332,7 @@ function updateSlotUI(cont, items, reqQty, d, deps) {
|
|
|
2329
2332
|
}
|
|
2330
2333
|
}
|
|
2331
2334
|
}
|
|
2332
|
-
function updatePricing(cont, items, reqQty, d,
|
|
2335
|
+
function updatePricing(cont, items, reqQty, d, paint) {
|
|
2333
2336
|
const pricingSection = cont.querySelector(
|
|
2334
2337
|
"[data-pricing-section]"
|
|
2335
2338
|
);
|
|
@@ -2338,14 +2341,19 @@ function updatePricing(cont, items, reqQty, d, calcDiscount, paint) {
|
|
|
2338
2341
|
return;
|
|
2339
2342
|
}
|
|
2340
2343
|
if (pricingSection) pricingSection.style.display = "";
|
|
2344
|
+
const lines = items.map((item) => ({
|
|
2345
|
+
unitCents: item.price,
|
|
2346
|
+
quantity: item.quantity || 1
|
|
2347
|
+
}));
|
|
2341
2348
|
let totalPrice = 0;
|
|
2342
|
-
for (
|
|
2343
|
-
totalPrice += items[i].price * (items[i].quantity || 1);
|
|
2344
|
-
}
|
|
2349
|
+
for (const line of lines) totalPrice += line.unitCents * line.quantity;
|
|
2345
2350
|
if (totalPrice > 0 && d.discountType) {
|
|
2346
2351
|
paint(
|
|
2347
2352
|
cont,
|
|
2348
|
-
|
|
2353
|
+
(0, import_core3.bundleSaleCents)(lines, {
|
|
2354
|
+
discountType: d.discountType,
|
|
2355
|
+
discountValue: d.discountValue ?? 0
|
|
2356
|
+
}),
|
|
2349
2357
|
totalPrice
|
|
2350
2358
|
);
|
|
2351
2359
|
}
|
|
@@ -2384,9 +2392,6 @@ function updateProgress(cont, overlay, items, reqQty, trans) {
|
|
|
2384
2392
|
}
|
|
2385
2393
|
}
|
|
2386
2394
|
|
|
2387
|
-
// src/renderers/mix-match.ts
|
|
2388
|
-
var import_core3 = require("@lime-bundles/core");
|
|
2389
|
-
|
|
2390
2395
|
// src/renderers/pricing-paint.ts
|
|
2391
2396
|
function updatePricing2(formatMoney) {
|
|
2392
2397
|
return (container, salePrice, comparePrice) => {
|
|
@@ -2761,7 +2766,6 @@ function renderMixMatchBundle(container, bundle, onAddToCart, onCleanup, current
|
|
|
2761
2766
|
discountType: bundle.discountConfig.discountType,
|
|
2762
2767
|
discountValue: bundle.discountConfig.discountValue
|
|
2763
2768
|
},
|
|
2764
|
-
(total, type, value) => (0, import_core3.calculateDiscount)(total, type, value),
|
|
2765
2769
|
updatePricing2(formatMoney)
|
|
2766
2770
|
);
|
|
2767
2771
|
updateProgress(shell.root, modal.overlay, selectedItems, requiredQty, t);
|
|
@@ -3290,6 +3294,9 @@ function renderBogoBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
3290
3294
|
}
|
|
3291
3295
|
|
|
3292
3296
|
// src/renderers/multi-step.ts
|
|
3297
|
+
var import_core6 = require("@lime-bundles/core");
|
|
3298
|
+
|
|
3299
|
+
// ../render/src/multi-step/body.ts
|
|
3293
3300
|
var import_core5 = require("@lime-bundles/core");
|
|
3294
3301
|
|
|
3295
3302
|
// ../render/src/multi-step/i18n.ts
|
|
@@ -3489,7 +3496,7 @@ function updateDoor(deps) {
|
|
|
3489
3496
|
target.parentElement.insertBefore(door, target);
|
|
3490
3497
|
}
|
|
3491
3498
|
}
|
|
3492
|
-
function updatePricing3(deps, data,
|
|
3499
|
+
function updatePricing3(deps, data, paint) {
|
|
3493
3500
|
const { container, steps, selections } = deps;
|
|
3494
3501
|
const pricingSection = container.querySelector(
|
|
3495
3502
|
"[data-pricing-section]"
|
|
@@ -3499,14 +3506,22 @@ function updatePricing3(deps, data, calcDiscount, paint) {
|
|
|
3499
3506
|
return;
|
|
3500
3507
|
}
|
|
3501
3508
|
if (pricingSection) pricingSection.style.display = "";
|
|
3509
|
+
const lines = [];
|
|
3502
3510
|
let totalPrice = 0;
|
|
3503
3511
|
for (const step of selections) {
|
|
3504
|
-
for (const pick of step)
|
|
3512
|
+
for (const pick of step) {
|
|
3513
|
+
const line = { unitCents: pick.price, quantity: pick.quantity || 1 };
|
|
3514
|
+
lines.push(line);
|
|
3515
|
+
totalPrice += line.unitCents * line.quantity;
|
|
3516
|
+
}
|
|
3505
3517
|
}
|
|
3506
3518
|
if (totalPrice > 0 && data.discountType) {
|
|
3507
3519
|
paint(
|
|
3508
3520
|
container,
|
|
3509
|
-
|
|
3521
|
+
(0, import_core5.bundleSaleCents)(lines, {
|
|
3522
|
+
discountType: data.discountType,
|
|
3523
|
+
discountValue: data.discountValue ?? 0
|
|
3524
|
+
}),
|
|
3510
3525
|
totalPrice
|
|
3511
3526
|
);
|
|
3512
3527
|
}
|
|
@@ -4074,7 +4089,7 @@ function renderMultiStepBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
4074
4089
|
variantQuantities: bundle.variantQuantities
|
|
4075
4090
|
};
|
|
4076
4091
|
const pools = steps.map(
|
|
4077
|
-
(_, i) => (0,
|
|
4092
|
+
(_, i) => (0, import_core6.productsForStep)(bundle, i).map((product) => {
|
|
4078
4093
|
const p = adaptProduct(product, bundle.id, {
|
|
4079
4094
|
quantities,
|
|
4080
4095
|
allowedVariantIds: null
|
|
@@ -4219,7 +4234,6 @@ function renderMultiStepBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
4219
4234
|
discountType: bundle.discountConfig.discountType,
|
|
4220
4235
|
discountValue: bundle.discountConfig.discountValue
|
|
4221
4236
|
},
|
|
4222
|
-
(total, type, value) => (0, import_core5.calculateDiscount)(total, type, value),
|
|
4223
4237
|
updatePricing2(formatMoney)
|
|
4224
4238
|
);
|
|
4225
4239
|
updateProgress2(bodyDeps);
|
|
@@ -4288,7 +4302,7 @@ function renderMultiStepBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
4288
4302
|
}
|
|
4289
4303
|
|
|
4290
4304
|
// src/lime-bundle.ts
|
|
4291
|
-
var
|
|
4305
|
+
var import_core8 = require("@lime-bundles/core");
|
|
4292
4306
|
|
|
4293
4307
|
// src/utils/input-mode.ts
|
|
4294
4308
|
var NAV_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -7340,13 +7354,13 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7340
7354
|
* no buyer/country/language is set.
|
|
7341
7355
|
*/
|
|
7342
7356
|
wrapQueryForContext(query) {
|
|
7343
|
-
return (0,
|
|
7357
|
+
return (0, import_core7.hasInContext)({
|
|
7344
7358
|
shopDomain: this.shopDomain,
|
|
7345
7359
|
accessToken: this.storefrontToken,
|
|
7346
7360
|
country: this.country,
|
|
7347
7361
|
language: this.language,
|
|
7348
7362
|
buyer: this.buyer
|
|
7349
|
-
}) ? (0,
|
|
7363
|
+
}) ? (0, import_core7.withInContext)(query) : query;
|
|
7350
7364
|
}
|
|
7351
7365
|
/** Buyer resolved once per fetch so the market gate can read the
|
|
7352
7366
|
* company location without invoking a callback resolver twice. */
|
|
@@ -7360,7 +7374,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7360
7374
|
* locations (B2B markets), or a legacy `market-id` match.
|
|
7361
7375
|
*/
|
|
7362
7376
|
isMarketHidden(bundle) {
|
|
7363
|
-
return !(0,
|
|
7377
|
+
return !(0, import_core7.isVisibleToBuyer)(bundle, {
|
|
7364
7378
|
marketId: this.marketId,
|
|
7365
7379
|
countryCode: this.country,
|
|
7366
7380
|
companyLocationId: this.resolvedBuyer?.companyLocationId
|
|
@@ -7382,7 +7396,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7382
7396
|
} catch {
|
|
7383
7397
|
this.resolvedBuyer = void 0;
|
|
7384
7398
|
}
|
|
7385
|
-
const client = (0,
|
|
7399
|
+
const client = (0, import_core7.createStorefrontClient)({
|
|
7386
7400
|
shopDomain: this.shopDomain,
|
|
7387
7401
|
accessToken: this.storefrontToken,
|
|
7388
7402
|
country: this.country,
|
|
@@ -7411,7 +7425,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7411
7425
|
handle
|
|
7412
7426
|
);
|
|
7413
7427
|
}
|
|
7414
|
-
const shopSettingsPromise = client.query(
|
|
7428
|
+
const shopSettingsPromise = client.query(import_core7.SHOP_SETTINGS_QUERY, void 0, {
|
|
7415
7429
|
signal: controller.signal
|
|
7416
7430
|
}).catch(() => null);
|
|
7417
7431
|
await bundlePromise;
|
|
@@ -7424,8 +7438,8 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7424
7438
|
const shopSettings = await shopSettingsPromise;
|
|
7425
7439
|
const customCss = shopSettings?.shop?.customCss?.value;
|
|
7426
7440
|
if (customCss) {
|
|
7427
|
-
(0,
|
|
7428
|
-
const sanitized = (0,
|
|
7441
|
+
(0, import_core7.injectCustomCss)(this.shopDomain, customCss);
|
|
7442
|
+
const sanitized = (0, import_core7.sanitizeCustomCss)(customCss);
|
|
7429
7443
|
if (sanitized.ok) this.shopCustomCss = sanitized.css;
|
|
7430
7444
|
}
|
|
7431
7445
|
this.renderBundles();
|
|
@@ -7440,7 +7454,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7440
7454
|
}
|
|
7441
7455
|
async fetchSingleBundle(client, signal) {
|
|
7442
7456
|
const data = await client.query(
|
|
7443
|
-
this.wrapQueryForContext(
|
|
7457
|
+
this.wrapQueryForContext(import_core7.BUNDLE_METAOBJECT_QUERY),
|
|
7444
7458
|
{ id: this.bundleGid },
|
|
7445
7459
|
{ signal }
|
|
7446
7460
|
);
|
|
@@ -7448,15 +7462,15 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7448
7462
|
this.bundles = [];
|
|
7449
7463
|
return;
|
|
7450
7464
|
}
|
|
7451
|
-
const parsed = (0,
|
|
7465
|
+
const parsed = (0, import_core7.parseMetaobjectBundle)(
|
|
7452
7466
|
data.metaobject.id,
|
|
7453
7467
|
data.metaobject.fields
|
|
7454
7468
|
);
|
|
7455
|
-
this.bundles = parsed && !this.isMarketHidden(parsed) ? [(0,
|
|
7469
|
+
this.bundles = parsed && !this.isMarketHidden(parsed) ? [(0, import_core7.convertBundleToPresentment)(parsed, this.currencyRate)] : [];
|
|
7456
7470
|
}
|
|
7457
7471
|
async fetchProductBundles(client, signal, productHandle) {
|
|
7458
7472
|
const data = await client.query(
|
|
7459
|
-
this.wrapQueryForContext(
|
|
7473
|
+
this.wrapQueryForContext(import_core7.BUNDLES_FOR_PRODUCT_QUERY),
|
|
7460
7474
|
{ handle: productHandle },
|
|
7461
7475
|
{ signal }
|
|
7462
7476
|
);
|
|
@@ -7467,12 +7481,12 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7467
7481
|
const refs = data.product.metafield?.references?.nodes ?? [];
|
|
7468
7482
|
const bundles = [];
|
|
7469
7483
|
for (const ref of refs) {
|
|
7470
|
-
const parsed = (0,
|
|
7484
|
+
const parsed = (0, import_core7.parseMetaobjectBundle)(ref.id, ref.fields);
|
|
7471
7485
|
if (parsed && !this.isMarketHidden(parsed)) {
|
|
7472
|
-
bundles.push((0,
|
|
7486
|
+
bundles.push((0, import_core7.convertBundleToPresentment)(parsed, this.currencyRate));
|
|
7473
7487
|
}
|
|
7474
7488
|
}
|
|
7475
|
-
this.bundles = (0,
|
|
7489
|
+
this.bundles = (0, import_core7.resolveAbTests)(bundles, (0, import_core7.getVisitorId)());
|
|
7476
7490
|
}
|
|
7477
7491
|
/**
|
|
7478
7492
|
* Dispatch add-to-cart with a cancelable event, then — unless a listener
|
|
@@ -7502,7 +7516,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7502
7516
|
*/
|
|
7503
7517
|
async defaultAddToCart(lines) {
|
|
7504
7518
|
if (typeof window === "undefined") return;
|
|
7505
|
-
const client = (0,
|
|
7519
|
+
const client = (0, import_core7.createStorefrontClient)({
|
|
7506
7520
|
shopDomain: this.shopDomain,
|
|
7507
7521
|
accessToken: this.storefrontToken
|
|
7508
7522
|
});
|
|
@@ -7531,7 +7545,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7531
7545
|
}
|
|
7532
7546
|
if (cartId) {
|
|
7533
7547
|
const res = await client.query(
|
|
7534
|
-
|
|
7548
|
+
import_core7.CART_LINES_ADD_MUTATION,
|
|
7535
7549
|
{ cartId, lines }
|
|
7536
7550
|
);
|
|
7537
7551
|
const payload = res.cartLinesAdd;
|
|
@@ -7550,7 +7564,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7550
7564
|
}
|
|
7551
7565
|
if (!checkoutUrl) {
|
|
7552
7566
|
const res = await client.query(
|
|
7553
|
-
|
|
7567
|
+
import_core7.CART_CREATE_MUTATION,
|
|
7554
7568
|
{ input: { lines } }
|
|
7555
7569
|
);
|
|
7556
7570
|
const payload = res.cartCreate;
|
|
@@ -7600,7 +7614,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7600
7614
|
* checkout matches the shopper's current build.
|
|
7601
7615
|
*/
|
|
7602
7616
|
async clearAbandonedBundleLines(client, cartId, dropSavedCart) {
|
|
7603
|
-
const res = await client.query(
|
|
7617
|
+
const res = await client.query(import_core7.CART_LINES_QUERY, {
|
|
7604
7618
|
cartId
|
|
7605
7619
|
});
|
|
7606
7620
|
if (!res.cart) {
|
|
@@ -7612,7 +7626,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7612
7626
|
).map((line) => line.id);
|
|
7613
7627
|
if (abandonedLineIds.length === 0) return cartId;
|
|
7614
7628
|
const removal = await client.query(
|
|
7615
|
-
|
|
7629
|
+
import_core7.CART_LINES_REMOVE_MUTATION,
|
|
7616
7630
|
{ cartId, lineIds: abandonedLineIds }
|
|
7617
7631
|
);
|
|
7618
7632
|
if (removal.cartLinesRemove?.userErrors?.length) {
|
|
@@ -7634,7 +7648,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7634
7648
|
const price = variant ? parseFloat(variant.price.amount) : 0;
|
|
7635
7649
|
return sum + price * line.quantity;
|
|
7636
7650
|
}, 0);
|
|
7637
|
-
(0,
|
|
7651
|
+
(0, import_core7.reportAddToCart)(
|
|
7638
7652
|
{ shopDomain: this.shopDomain, appUrl: this.appUrl },
|
|
7639
7653
|
{
|
|
7640
7654
|
bundleGid: bundle.id,
|
|
@@ -7674,7 +7688,7 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7674
7688
|
container.setAttribute("data-bundle-type", bundle.bundleType);
|
|
7675
7689
|
container.setAttribute("data-bundle-gid", bundle.id);
|
|
7676
7690
|
if (bundle.endsAt) container.setAttribute("data-ends-at", bundle.endsAt);
|
|
7677
|
-
(0,
|
|
7691
|
+
(0, import_core8.applyWidgetConfigVars)(container, bundle.widgetConfig);
|
|
7678
7692
|
this.renderCleanups.push(trackInputMode(container));
|
|
7679
7693
|
const dispatch = (lines) => this.handleAddToCart(bundle, lines);
|
|
7680
7694
|
const registerCleanup = (fn) => this.renderCleanups.push(fn);
|
|
@@ -7725,8 +7739,8 @@ var LimeBundleElement = class extends HTMLElement {
|
|
|
7725
7739
|
}
|
|
7726
7740
|
setupImpressionFor(bundle, element) {
|
|
7727
7741
|
if (!this.analyticsEnabled || !this.appUrl) return;
|
|
7728
|
-
const cleanup = (0,
|
|
7729
|
-
(0,
|
|
7742
|
+
const cleanup = (0, import_core7.observeImpression)(element, () => {
|
|
7743
|
+
(0, import_core7.reportImpression)(
|
|
7730
7744
|
{ shopDomain: this.shopDomain, appUrl: this.appUrl },
|
|
7731
7745
|
{
|
|
7732
7746
|
bundleGid: bundle.id,
|
package/dist/index.js
CHANGED
|
@@ -536,11 +536,13 @@ function buildWidgetShell(typeClass, opts) {
|
|
|
536
536
|
const countdown = box("div", "lb-bundle-countdown", {
|
|
537
537
|
"data-countdown": ""
|
|
538
538
|
});
|
|
539
|
-
const label2 = box("
|
|
540
|
-
|
|
539
|
+
const label2 = box("div", "lb-bundle-countdown__label");
|
|
540
|
+
const labelText = document.createElement("span");
|
|
541
|
+
labelText.textContent = opts.countdownLabel ?? "Limited time offer";
|
|
542
|
+
label2.appendChild(labelText);
|
|
541
543
|
countdown.appendChild(label2);
|
|
542
544
|
countdown.appendChild(
|
|
543
|
-
box("span", "lb-bundle-
|
|
545
|
+
box("span", "lb-bundle-countdown__timer", {
|
|
544
546
|
"data-countdown-timer": ""
|
|
545
547
|
})
|
|
546
548
|
);
|
|
@@ -760,7 +762,7 @@ var DEFAULT_STRINGS = {
|
|
|
760
762
|
allTypes: "All",
|
|
761
763
|
editSelection: "Edit selection",
|
|
762
764
|
addToCart: "Add to cart",
|
|
763
|
-
bundlePrice: "Bundle
|
|
765
|
+
bundlePrice: "Bundle total",
|
|
764
766
|
save: "Save",
|
|
765
767
|
complete: "Complete",
|
|
766
768
|
ofSelected: "__COUNT__ of __TOTAL__ added",
|
|
@@ -2296,6 +2298,7 @@ function buildSlotCard(item, trans, formatMoney, removable, onRemove, onEdit) {
|
|
|
2296
2298
|
}
|
|
2297
2299
|
|
|
2298
2300
|
// ../render/src/mix-match/slots.ts
|
|
2301
|
+
import { bundleSaleCents } from "@lime-bundles/core";
|
|
2299
2302
|
function updateSlotUI(cont, items, reqQty, d, deps) {
|
|
2300
2303
|
const trans = d.translations || {};
|
|
2301
2304
|
const slotsWrap = cont.querySelector("[data-selection-slots]");
|
|
@@ -2328,7 +2331,7 @@ function updateSlotUI(cont, items, reqQty, d, deps) {
|
|
|
2328
2331
|
}
|
|
2329
2332
|
}
|
|
2330
2333
|
}
|
|
2331
|
-
function updatePricing(cont, items, reqQty, d,
|
|
2334
|
+
function updatePricing(cont, items, reqQty, d, paint) {
|
|
2332
2335
|
const pricingSection = cont.querySelector(
|
|
2333
2336
|
"[data-pricing-section]"
|
|
2334
2337
|
);
|
|
@@ -2337,14 +2340,19 @@ function updatePricing(cont, items, reqQty, d, calcDiscount, paint) {
|
|
|
2337
2340
|
return;
|
|
2338
2341
|
}
|
|
2339
2342
|
if (pricingSection) pricingSection.style.display = "";
|
|
2343
|
+
const lines = items.map((item) => ({
|
|
2344
|
+
unitCents: item.price,
|
|
2345
|
+
quantity: item.quantity || 1
|
|
2346
|
+
}));
|
|
2340
2347
|
let totalPrice = 0;
|
|
2341
|
-
for (
|
|
2342
|
-
totalPrice += items[i].price * (items[i].quantity || 1);
|
|
2343
|
-
}
|
|
2348
|
+
for (const line of lines) totalPrice += line.unitCents * line.quantity;
|
|
2344
2349
|
if (totalPrice > 0 && d.discountType) {
|
|
2345
2350
|
paint(
|
|
2346
2351
|
cont,
|
|
2347
|
-
|
|
2352
|
+
bundleSaleCents(lines, {
|
|
2353
|
+
discountType: d.discountType,
|
|
2354
|
+
discountValue: d.discountValue ?? 0
|
|
2355
|
+
}),
|
|
2348
2356
|
totalPrice
|
|
2349
2357
|
);
|
|
2350
2358
|
}
|
|
@@ -2383,9 +2391,6 @@ function updateProgress(cont, overlay, items, reqQty, trans) {
|
|
|
2383
2391
|
}
|
|
2384
2392
|
}
|
|
2385
2393
|
|
|
2386
|
-
// src/renderers/mix-match.ts
|
|
2387
|
-
import { calculateDiscount } from "@lime-bundles/core";
|
|
2388
|
-
|
|
2389
2394
|
// src/renderers/pricing-paint.ts
|
|
2390
2395
|
function updatePricing2(formatMoney) {
|
|
2391
2396
|
return (container, salePrice, comparePrice) => {
|
|
@@ -2760,7 +2765,6 @@ function renderMixMatchBundle(container, bundle, onAddToCart, onCleanup, current
|
|
|
2760
2765
|
discountType: bundle.discountConfig.discountType,
|
|
2761
2766
|
discountValue: bundle.discountConfig.discountValue
|
|
2762
2767
|
},
|
|
2763
|
-
(total, type, value) => calculateDiscount(total, type, value),
|
|
2764
2768
|
updatePricing2(formatMoney)
|
|
2765
2769
|
);
|
|
2766
2770
|
updateProgress(shell.root, modal.overlay, selectedItems, requiredQty, t);
|
|
@@ -3297,10 +3301,14 @@ function renderBogoBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
3297
3301
|
|
|
3298
3302
|
// src/renderers/multi-step.ts
|
|
3299
3303
|
import {
|
|
3300
|
-
calculateDiscount as calculateDiscount2,
|
|
3301
3304
|
productsForStep
|
|
3302
3305
|
} from "@lime-bundles/core";
|
|
3303
3306
|
|
|
3307
|
+
// ../render/src/multi-step/body.ts
|
|
3308
|
+
import {
|
|
3309
|
+
bundleSaleCents as bundleSaleCents2
|
|
3310
|
+
} from "@lime-bundles/core";
|
|
3311
|
+
|
|
3304
3312
|
// ../render/src/multi-step/i18n.ts
|
|
3305
3313
|
function stepOfLabel(i, total, t) {
|
|
3306
3314
|
return fill(t.stepOf || "Step __STEP__ of __TOTAL__", {
|
|
@@ -3498,7 +3506,7 @@ function updateDoor(deps) {
|
|
|
3498
3506
|
target.parentElement.insertBefore(door, target);
|
|
3499
3507
|
}
|
|
3500
3508
|
}
|
|
3501
|
-
function updatePricing3(deps, data,
|
|
3509
|
+
function updatePricing3(deps, data, paint) {
|
|
3502
3510
|
const { container, steps, selections } = deps;
|
|
3503
3511
|
const pricingSection = container.querySelector(
|
|
3504
3512
|
"[data-pricing-section]"
|
|
@@ -3508,14 +3516,22 @@ function updatePricing3(deps, data, calcDiscount, paint) {
|
|
|
3508
3516
|
return;
|
|
3509
3517
|
}
|
|
3510
3518
|
if (pricingSection) pricingSection.style.display = "";
|
|
3519
|
+
const lines = [];
|
|
3511
3520
|
let totalPrice = 0;
|
|
3512
3521
|
for (const step of selections) {
|
|
3513
|
-
for (const pick of step)
|
|
3522
|
+
for (const pick of step) {
|
|
3523
|
+
const line = { unitCents: pick.price, quantity: pick.quantity || 1 };
|
|
3524
|
+
lines.push(line);
|
|
3525
|
+
totalPrice += line.unitCents * line.quantity;
|
|
3526
|
+
}
|
|
3514
3527
|
}
|
|
3515
3528
|
if (totalPrice > 0 && data.discountType) {
|
|
3516
3529
|
paint(
|
|
3517
3530
|
container,
|
|
3518
|
-
|
|
3531
|
+
bundleSaleCents2(lines, {
|
|
3532
|
+
discountType: data.discountType,
|
|
3533
|
+
discountValue: data.discountValue ?? 0
|
|
3534
|
+
}),
|
|
3519
3535
|
totalPrice
|
|
3520
3536
|
);
|
|
3521
3537
|
}
|
|
@@ -4228,7 +4244,6 @@ function renderMultiStepBundle(container, bundle, onAddToCart, onCleanup) {
|
|
|
4228
4244
|
discountType: bundle.discountConfig.discountType,
|
|
4229
4245
|
discountValue: bundle.discountConfig.discountValue
|
|
4230
4246
|
},
|
|
4231
|
-
(total, type, value) => calculateDiscount2(total, type, value),
|
|
4232
4247
|
updatePricing2(formatMoney)
|
|
4233
4248
|
);
|
|
4234
4249
|
updateProgress2(bodyDeps);
|