feeef 0.12.7 → 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.
|
@@ -229,9 +229,12 @@ export interface ProductOffer {
|
|
|
229
229
|
code: string;
|
|
230
230
|
title: string;
|
|
231
231
|
subtitle?: string;
|
|
232
|
-
price
|
|
233
|
-
|
|
234
|
-
|
|
232
|
+
/** Unit price override; API may emit `null` when unset. */
|
|
233
|
+
price?: number | null;
|
|
234
|
+
/** Minimum qty for this offer; API may emit `null` when unset. */
|
|
235
|
+
minQuantity?: number | null;
|
|
236
|
+
/** Maximum qty for this offer; API may emit `null` when unset. */
|
|
237
|
+
maxQuantity?: number | null;
|
|
235
238
|
freeShipping?: boolean;
|
|
236
239
|
}
|
|
237
240
|
/**
|
|
@@ -5,6 +5,19 @@ export type ProductOfferPolicySource = Pick<ProductEntity, 'offers' | 'forceOffe
|
|
|
5
5
|
force_offer?: boolean | null;
|
|
6
6
|
default_offer_code?: string | null;
|
|
7
7
|
};
|
|
8
|
+
/**
|
|
9
|
+
* Coerce API offer quantity / price bounds.
|
|
10
|
+
*
|
|
11
|
+
* JSON often emits `null` for unset min/max. `Math.min(n, null)` is `0` in JS
|
|
12
|
+
* because `null` coerces to `0` — that zeroed cart qty after default/force offer
|
|
13
|
+
* apply. Only finite numbers are valid bounds; `null` / `undefined` / `NaN` mean
|
|
14
|
+
* "no limit" (or "no override" for price).
|
|
15
|
+
*/
|
|
16
|
+
export declare function finiteOfferNumber(value: number | string | null | undefined): number | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Clamp cart quantity to an offer's min/max, ignoring nullish/non-finite bounds.
|
|
19
|
+
*/
|
|
20
|
+
export declare function clampQuantityToOfferLimits(offer: Pick<ProductOffer, 'minQuantity' | 'maxQuantity'>, quantity: number): number;
|
|
8
21
|
/**
|
|
9
22
|
* Returns [defaultOfferCode] only when it exists in [offers]; otherwise null.
|
|
10
23
|
* Use whenever persisting or applying a default so stale codes never leak.
|
|
@@ -88,13 +88,6 @@ export declare class CartService extends NotifiableService {
|
|
|
88
88
|
* - Forced+default: always keep the forced offer
|
|
89
89
|
*/
|
|
90
90
|
private applyProductOfferPolicy;
|
|
91
|
-
/**
|
|
92
|
-
* Clamps the quantity to be within the offer's min/max range
|
|
93
|
-
* @param offer - The offer containing quantity constraints
|
|
94
|
-
* @param quantity - The quantity to clamp
|
|
95
|
-
* @returns The clamped quantity value
|
|
96
|
-
*/
|
|
97
|
-
private clampQuantityToOfferLimits;
|
|
98
91
|
/**
|
|
99
92
|
* Update item by unique key (product ID + variant + offer + addons).
|
|
100
93
|
* @param item - The item to identify the cart item to update.
|