@osimart/create-storefront 1.0.24 → 1.0.25
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.
|
@@ -563,16 +563,39 @@ export function createProductDetail({ product, settings = {}, loading = false }
|
|
|
563
563
|
const originalPriceRange = computed(() => pricing.value.original);
|
|
564
564
|
/** The sale boxes under the price (tiers of 2+ items), each { id, text, reached, applied }. */
|
|
565
565
|
const discountBadges = computed(() => pricing.value.badges ?? []);
|
|
566
|
+
/**
|
|
567
|
+
* What the customization adds to every unit: per-unit fees plus the price of
|
|
568
|
+
* each add-on picked. The prices shown on the page include it; `pricing`
|
|
569
|
+
* itself (sales, "Save %", hasPrice) stays on the product's own price.
|
|
570
|
+
*/
|
|
571
|
+
const extraPerUnit = computed(() =>
|
|
572
|
+
round2((Number(customization.deltaPerUnit.value) || 0) + (Number(customization.addonsPerUnit.value) || 0))
|
|
573
|
+
);
|
|
574
|
+
|
|
575
|
+
/** A price range with the extra added. A bound with no price stays unpriced (never "$5"). */
|
|
576
|
+
function withExtra(range) {
|
|
577
|
+
const extra = extraPerUnit.value;
|
|
578
|
+
if (!range || !(extra > 0)) return range;
|
|
579
|
+
const add = (n) => (Number(n) > 0 ? round2(Number(n) + extra) : n);
|
|
580
|
+
return { min: add(range.min), max: add(range.max) };
|
|
581
|
+
}
|
|
582
|
+
|
|
566
583
|
/**
|
|
567
584
|
* The line total for the quantity picked — { quantity, before, after, saving,
|
|
568
585
|
* text: { before, after, saving } } — or null (1 item, or no single price).
|
|
586
|
+
* Includes the customization extra for every item; the saving is unchanged.
|
|
569
587
|
*/
|
|
570
588
|
const lineTotal = computed(() => {
|
|
571
589
|
const t = pricing.value.total;
|
|
572
590
|
if (!t) return null;
|
|
591
|
+
const extra = round2(extraPerUnit.value * t.quantity);
|
|
592
|
+
const before = round2(t.before + extra);
|
|
593
|
+
const after = round2(t.after + extra);
|
|
573
594
|
return {
|
|
574
595
|
...t,
|
|
575
|
-
|
|
596
|
+
before,
|
|
597
|
+
after,
|
|
598
|
+
text: { before: formatMoney(before), after: formatMoney(after), saving: formatMoney(t.saving) },
|
|
576
599
|
};
|
|
577
600
|
});
|
|
578
601
|
/** The same, as one line (older callers). */
|
|
@@ -592,7 +615,7 @@ export function createProductDetail({ product, settings = {}, loading = false }
|
|
|
592
615
|
return Math.round(((was - now) / was) * 100);
|
|
593
616
|
});
|
|
594
617
|
|
|
595
|
-
const priceText = computed(() => formatRange(priceRange.value));
|
|
618
|
+
const priceText = computed(() => formatRange(withExtra(priceRange.value)));
|
|
596
619
|
|
|
597
620
|
/**
|
|
598
621
|
* Whether the selection has a real price. A product (or variant) with no
|
|
@@ -604,9 +627,9 @@ export function createProductDetail({ product, settings = {}, loading = false }
|
|
|
604
627
|
});
|
|
605
628
|
const comparePriceText = computed(() =>
|
|
606
629
|
pricing.value.was
|
|
607
|
-
? formatRange(pricing.value.was)
|
|
630
|
+
? formatRange(withExtra(pricing.value.was))
|
|
608
631
|
: isOnSale.value
|
|
609
|
-
? formatRange(originalPriceRange.value)
|
|
632
|
+
? formatRange(withExtra(originalPriceRange.value))
|
|
610
633
|
: ""
|
|
611
634
|
);
|
|
612
635
|
|
|
@@ -954,6 +977,7 @@ export function createProductDetail({ product, settings = {}, loading = false }
|
|
|
954
977
|
|
|
955
978
|
// price
|
|
956
979
|
pricing,
|
|
980
|
+
extraPerUnit,
|
|
957
981
|
priceRange,
|
|
958
982
|
originalPriceRange,
|
|
959
983
|
discountMessage,
|
|
@@ -1015,4 +1039,4 @@ export function provideProductDetail(context) {
|
|
|
1015
1039
|
*/
|
|
1016
1040
|
export function useProductDetail() {
|
|
1017
1041
|
return inject(PRODUCT_DETAIL_KEY, null);
|
|
1018
|
-
}
|
|
1042
|
+
}
|
package/package.json
CHANGED