@moonbase.sh/storefront-api 0.4.58 → 0.4.60
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 +10 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +10 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1483,6 +1483,16 @@ var OfferUtils = class _OfferUtils {
|
|
|
1483
1483
|
console.warn("Unsupported offer condition found:", offer.condition);
|
|
1484
1484
|
return false;
|
|
1485
1485
|
}
|
|
1486
|
+
// The relevant targets of an offer with more than a single target needs to:
|
|
1487
|
+
// a. Not be owned, or all targets need to be owned
|
|
1488
|
+
// b. Not already in the cart
|
|
1489
|
+
static relevantTargets(offer, cartItems) {
|
|
1490
|
+
if (Array.isArray(offer.target)) {
|
|
1491
|
+
const allOwned = offer.target.every((i) => i.owned);
|
|
1492
|
+
return offer.target.filter((i) => (allOwned || !i.owned) && cartItems.every((l) => l.type !== i.type || l.id !== i.id));
|
|
1493
|
+
}
|
|
1494
|
+
return [offer.target];
|
|
1495
|
+
}
|
|
1486
1496
|
static applyToVariation(offer, variation) {
|
|
1487
1497
|
const discount = DiscountUtils.apply(offer.discount, variation.price);
|
|
1488
1498
|
return {
|
package/dist/index.d.cts
CHANGED
|
@@ -37784,6 +37784,7 @@ type ProblemDetails = z.infer<typeof problemDetailsSchema>;
|
|
|
37784
37784
|
|
|
37785
37785
|
declare class OfferUtils {
|
|
37786
37786
|
static eligible(offer: StorefrontOffer, order: Order): boolean;
|
|
37787
|
+
static relevantTargets(offer: StorefrontOffer, cartItems: LineItem[]): (StorefrontProduct | StorefrontBundle)[];
|
|
37787
37788
|
static applyToVariation(offer: StorefrontOffer, variation: PricingVariation): PricingVariation;
|
|
37788
37789
|
private static targetContainsBundle;
|
|
37789
37790
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -37784,6 +37784,7 @@ type ProblemDetails = z.infer<typeof problemDetailsSchema>;
|
|
|
37784
37784
|
|
|
37785
37785
|
declare class OfferUtils {
|
|
37786
37786
|
static eligible(offer: StorefrontOffer, order: Order): boolean;
|
|
37787
|
+
static relevantTargets(offer: StorefrontOffer, cartItems: LineItem[]): (StorefrontProduct | StorefrontBundle)[];
|
|
37787
37788
|
static applyToVariation(offer: StorefrontOffer, variation: PricingVariation): PricingVariation;
|
|
37788
37789
|
private static targetContainsBundle;
|
|
37789
37790
|
}
|
package/dist/index.js
CHANGED
|
@@ -1427,6 +1427,16 @@ var OfferUtils = class _OfferUtils {
|
|
|
1427
1427
|
console.warn("Unsupported offer condition found:", offer.condition);
|
|
1428
1428
|
return false;
|
|
1429
1429
|
}
|
|
1430
|
+
// The relevant targets of an offer with more than a single target needs to:
|
|
1431
|
+
// a. Not be owned, or all targets need to be owned
|
|
1432
|
+
// b. Not already in the cart
|
|
1433
|
+
static relevantTargets(offer, cartItems) {
|
|
1434
|
+
if (Array.isArray(offer.target)) {
|
|
1435
|
+
const allOwned = offer.target.every((i) => i.owned);
|
|
1436
|
+
return offer.target.filter((i) => (allOwned || !i.owned) && cartItems.every((l) => l.type !== i.type || l.id !== i.id));
|
|
1437
|
+
}
|
|
1438
|
+
return [offer.target];
|
|
1439
|
+
}
|
|
1430
1440
|
static applyToVariation(offer, variation) {
|
|
1431
1441
|
const discount = DiscountUtils.apply(offer.discount, variation.price);
|
|
1432
1442
|
return {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moonbase.sh/storefront-api",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.60",
|
|
5
5
|
"description": "Package to let you build storefronts with Moonbase.sh as payment and delivery provider",
|
|
6
6
|
"author": "Tobias Lønnerød Madsen <m@dsen.tv>",
|
|
7
7
|
"license": "MIT",
|