feeef 0.12.6 → 0.12.8
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/build/index.js +51 -25
- package/build/index.js.map +1 -1
- package/build/src/core/entities/product.d.ts +6 -3
- package/build/src/core/entities/product_offer_policy.d.ts +13 -0
- package/build/src/feeef/repositories/store_templates.d.ts +11 -0
- package/build/src/feeef/services/cart.d.ts +0 -7
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -2966,6 +2966,14 @@ var StoreTemplatesRepository = class extends ModelRepository {
|
|
|
2966
2966
|
});
|
|
2967
2967
|
return toListResponse3(res.data);
|
|
2968
2968
|
}
|
|
2969
|
+
/**
|
|
2970
|
+
* Platform default Lithium theme (`GET /store_templates/default`).
|
|
2971
|
+
* Configured via `templateMarketplace.defaultTemplateId`.
|
|
2972
|
+
*/
|
|
2973
|
+
async getDefault() {
|
|
2974
|
+
const res = await this.client.get(`/${this.resource}/default`);
|
|
2975
|
+
return res.data;
|
|
2976
|
+
}
|
|
2969
2977
|
async fork(options) {
|
|
2970
2978
|
const res = await this.client.post(`/${this.resource}/${options.fromId}/fork`, {
|
|
2971
2979
|
storeId: options.storeId,
|
|
@@ -3123,6 +3131,27 @@ function shouldSuppressPixelEvents(order) {
|
|
|
3123
3131
|
}
|
|
3124
3132
|
|
|
3125
3133
|
// src/core/entities/product_offer_policy.ts
|
|
3134
|
+
function finiteOfferNumber(value) {
|
|
3135
|
+
if (value === null || value === void 0 || value === "") return void 0;
|
|
3136
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
3137
|
+
return Number.isFinite(n) ? n : void 0;
|
|
3138
|
+
}
|
|
3139
|
+
function clampQuantityToOfferLimits(offer, quantity) {
|
|
3140
|
+
let q = finiteOfferNumber(quantity);
|
|
3141
|
+
if (q === void 0 || q < 0) q = 1;
|
|
3142
|
+
const minQ = finiteOfferNumber(offer.minQuantity);
|
|
3143
|
+
const maxQ = finiteOfferNumber(offer.maxQuantity);
|
|
3144
|
+
if (minQ !== void 0 && minQ > 0) {
|
|
3145
|
+
q = Math.max(q, minQ);
|
|
3146
|
+
}
|
|
3147
|
+
if (maxQ !== void 0 && maxQ > 0) {
|
|
3148
|
+
q = Math.min(q, maxQ);
|
|
3149
|
+
}
|
|
3150
|
+
if (minQ !== void 0 && maxQ !== void 0 && minQ > 0 && maxQ > 0 && minQ > maxQ) {
|
|
3151
|
+
q = minQ;
|
|
3152
|
+
}
|
|
3153
|
+
return q;
|
|
3154
|
+
}
|
|
3126
3155
|
function readForceOffer(product) {
|
|
3127
3156
|
return product.forceOffer === true || product.force_offer === true;
|
|
3128
3157
|
}
|
|
@@ -3341,33 +3370,18 @@ var CartService = class extends NotifiableService {
|
|
|
3341
3370
|
applyProductOfferPolicy(item) {
|
|
3342
3371
|
const forced = resolveForcedProductOffer(item.product);
|
|
3343
3372
|
if (forced) {
|
|
3344
|
-
const quantity =
|
|
3373
|
+
const quantity = clampQuantityToOfferLimits(forced, item.quantity);
|
|
3345
3374
|
return { ...item, offer: forced, quantity };
|
|
3346
3375
|
}
|
|
3347
3376
|
if (!item.offer) {
|
|
3348
3377
|
const initial = resolveInitialProductOffer(item.product);
|
|
3349
3378
|
if (initial) {
|
|
3350
|
-
const quantity =
|
|
3379
|
+
const quantity = clampQuantityToOfferLimits(initial, item.quantity);
|
|
3351
3380
|
return { ...item, offer: initial, quantity };
|
|
3352
3381
|
}
|
|
3353
3382
|
}
|
|
3354
3383
|
return item;
|
|
3355
3384
|
}
|
|
3356
|
-
/**
|
|
3357
|
-
* Clamps the quantity to be within the offer's min/max range
|
|
3358
|
-
* @param offer - The offer containing quantity constraints
|
|
3359
|
-
* @param quantity - The quantity to clamp
|
|
3360
|
-
* @returns The clamped quantity value
|
|
3361
|
-
*/
|
|
3362
|
-
clampQuantityToOfferLimits(offer, quantity) {
|
|
3363
|
-
if (offer.minQuantity !== void 0) {
|
|
3364
|
-
quantity = Math.max(quantity, offer.minQuantity);
|
|
3365
|
-
}
|
|
3366
|
-
if (offer.maxQuantity !== void 0) {
|
|
3367
|
-
quantity = Math.min(quantity, offer.maxQuantity);
|
|
3368
|
-
}
|
|
3369
|
-
return quantity;
|
|
3370
|
-
}
|
|
3371
3385
|
/**
|
|
3372
3386
|
* Update item by unique key (product ID + variant + offer + addons).
|
|
3373
3387
|
* @param item - The item to identify the cart item to update.
|
|
@@ -3379,7 +3393,7 @@ var CartService = class extends NotifiableService {
|
|
|
3379
3393
|
const currentItem = this.items[index];
|
|
3380
3394
|
const newItem = { ...currentItem, ...updates };
|
|
3381
3395
|
if (newItem.offer) {
|
|
3382
|
-
newItem.quantity =
|
|
3396
|
+
newItem.quantity = clampQuantityToOfferLimits(newItem.offer, newItem.quantity);
|
|
3383
3397
|
}
|
|
3384
3398
|
this.items[index] = newItem;
|
|
3385
3399
|
this.cachedSubtotal = null;
|
|
@@ -3395,6 +3409,12 @@ var CartService = class extends NotifiableService {
|
|
|
3395
3409
|
updateCurrentItem(updates, notify = true) {
|
|
3396
3410
|
if (!this.currentItem) return;
|
|
3397
3411
|
this.currentItem = { ...this.currentItem, ...updates };
|
|
3412
|
+
if (this.currentItem.offer) {
|
|
3413
|
+
this.currentItem.quantity = clampQuantityToOfferLimits(
|
|
3414
|
+
this.currentItem.offer,
|
|
3415
|
+
this.currentItem.quantity
|
|
3416
|
+
);
|
|
3417
|
+
}
|
|
3398
3418
|
const existingItemIndex = this.findItemIndex(this.currentItem);
|
|
3399
3419
|
if (existingItemIndex !== -1) {
|
|
3400
3420
|
this.items[existingItemIndex] = this.currentItem;
|
|
@@ -3584,12 +3604,14 @@ var CartService = class extends NotifiableService {
|
|
|
3584
3604
|
}
|
|
3585
3605
|
}
|
|
3586
3606
|
if (offer) {
|
|
3587
|
-
|
|
3588
|
-
|
|
3607
|
+
const offerPrice = finiteOfferNumber(offer.price);
|
|
3608
|
+
if (offerPrice !== void 0) {
|
|
3609
|
+
price = offerPrice;
|
|
3589
3610
|
discount = 0;
|
|
3590
3611
|
}
|
|
3591
3612
|
}
|
|
3592
|
-
|
|
3613
|
+
const safeQty = finiteOfferNumber(quantity) ?? 0;
|
|
3614
|
+
let total = (price - discount) * safeQty;
|
|
3593
3615
|
if (addons && product.addons) {
|
|
3594
3616
|
for (const [addonId, addonQuantity] of Object.entries(addons)) {
|
|
3595
3617
|
const addon = product.addons.find((a) => a.title === addonId);
|
|
@@ -3607,8 +3629,10 @@ var CartService = class extends NotifiableService {
|
|
|
3607
3629
|
* @returns boolean indicating if the offer is valid for the quantity
|
|
3608
3630
|
*/
|
|
3609
3631
|
isOfferValidForQuantity(offer, quantity) {
|
|
3610
|
-
|
|
3611
|
-
|
|
3632
|
+
const minQ = finiteOfferNumber(offer.minQuantity);
|
|
3633
|
+
const maxQ = finiteOfferNumber(offer.maxQuantity);
|
|
3634
|
+
if (minQ !== void 0 && minQ > 0 && quantity < minQ) return false;
|
|
3635
|
+
if (maxQ !== void 0 && maxQ > 0 && quantity > maxQ) return false;
|
|
3612
3636
|
return true;
|
|
3613
3637
|
}
|
|
3614
3638
|
/**
|
|
@@ -3623,7 +3647,7 @@ var CartService = class extends NotifiableService {
|
|
|
3623
3647
|
if (next === "blocked") return;
|
|
3624
3648
|
const updatedItem = { ...existingItem, offer: next };
|
|
3625
3649
|
if (next) {
|
|
3626
|
-
updatedItem.quantity =
|
|
3650
|
+
updatedItem.quantity = clampQuantityToOfferLimits(next, existingItem.quantity);
|
|
3627
3651
|
}
|
|
3628
3652
|
this.updateItem(item, updatedItem);
|
|
3629
3653
|
this.cachedSubtotal = null;
|
|
@@ -3639,7 +3663,7 @@ var CartService = class extends NotifiableService {
|
|
|
3639
3663
|
if (next === "blocked") return;
|
|
3640
3664
|
const updatedItem = { ...this.currentItem, offer: next };
|
|
3641
3665
|
if (next) {
|
|
3642
|
-
updatedItem.quantity =
|
|
3666
|
+
updatedItem.quantity = clampQuantityToOfferLimits(next, this.currentItem.quantity);
|
|
3643
3667
|
}
|
|
3644
3668
|
this.updateCurrentItem(updatedItem, true);
|
|
3645
3669
|
this.cachedSubtotal = null;
|
|
@@ -5971,6 +5995,7 @@ export {
|
|
|
5971
5995
|
batchSummaryAllFailed,
|
|
5972
5996
|
batchSummaryHasFailures,
|
|
5973
5997
|
batchUpdateManyBody,
|
|
5998
|
+
clampQuantityToOfferLimits,
|
|
5974
5999
|
convertDartColorToCssNumber,
|
|
5975
6000
|
convertOrderEntityToOrderTrackEntity,
|
|
5976
6001
|
createFeeefTransmit,
|
|
@@ -5979,6 +6004,7 @@ export {
|
|
|
5979
6004
|
cssColorToHslString,
|
|
5980
6005
|
dartColorToCssColor,
|
|
5981
6006
|
defaultVoiceTtsTokenEstimates,
|
|
6007
|
+
finiteOfferNumber,
|
|
5982
6008
|
formatProductLandingPageOrderReference,
|
|
5983
6009
|
formatProductOrderReference,
|
|
5984
6010
|
generatePublicIntegrationsData,
|