@wocart/storefront 1.17.0 → 1.18.0
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/CHANGELOG.md +15 -0
- package/dist/basket.js +4 -0
- package/dist/domain.d.ts +2 -0
- package/dist/domain.js +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ follows [semantic versioning](https://semver.org/): breaking changes ship only
|
|
|
5
5
|
in a new major version, and an export is marked `@deprecated` for at least one
|
|
6
6
|
minor release before a major removes it.
|
|
7
7
|
|
|
8
|
+
## 1.18.0 — 2026-10-21
|
|
9
|
+
|
|
10
|
+
The basket carries the offer a shopper chose for a line, so a quantity tier
|
|
11
|
+
that two offers share is priced as the shopper picked it.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `BasketLine.offerId` (optional): the offer chosen for the line. `addLine`
|
|
16
|
+
keeps it; a plain add to the line keeps the chosen offer, and a later explicit
|
|
17
|
+
choice replaces it. A stored offer survives a reload; a value that is not a
|
|
18
|
+
string is dropped.
|
|
19
|
+
- `toOrderItems` and `BasketStore.toOrderItems()` send `offerId` with the line,
|
|
20
|
+
so checkout and cart validation receive the choice. A line that chose no offer
|
|
21
|
+
sends none.
|
|
22
|
+
|
|
8
23
|
## 1.17.0 — 2026-10-18
|
|
9
24
|
|
|
10
25
|
### Added
|
package/dist/basket.js
CHANGED
|
@@ -107,6 +107,7 @@ function sanitizeLine(raw, maxQuantity) {
|
|
|
107
107
|
unitPrice: Number.isFinite(unitPrice) && unitPrice >= 0 ? unitPrice : 0,
|
|
108
108
|
href: typeof line.href === "string" ? line.href : undefined,
|
|
109
109
|
image: typeof line.image === "string" ? line.image : undefined,
|
|
110
|
+
offerId: typeof line.offerId === "string" && line.offerId ? line.offerId : undefined,
|
|
110
111
|
};
|
|
111
112
|
}
|
|
112
113
|
function normalizeLines(lines, maxLines, maxQuantity) {
|
|
@@ -119,6 +120,8 @@ function normalizeLines(lines, maxLines, maxQuantity) {
|
|
|
119
120
|
existing.variantLabel ??= line.variantLabel;
|
|
120
121
|
existing.image ??= line.image;
|
|
121
122
|
existing.href ??= line.href;
|
|
123
|
+
// The newest explicit choice of offer wins; a plain add keeps the one chosen.
|
|
124
|
+
existing.offerId = line.offerId ?? existing.offerId;
|
|
122
125
|
}
|
|
123
126
|
else {
|
|
124
127
|
merged.set(key, { ...line });
|
|
@@ -143,6 +146,7 @@ export function toOrderItems(lines) {
|
|
|
143
146
|
variantLabel: line.variantLabel ?? undefined,
|
|
144
147
|
quantity: line.quantity,
|
|
145
148
|
pricePerUnit: line.unitPrice,
|
|
149
|
+
...(line.offerId !== undefined ? { offerId: line.offerId } : {}),
|
|
146
150
|
}));
|
|
147
151
|
}
|
|
148
152
|
/**
|
package/dist/domain.d.ts
CHANGED
|
@@ -75,6 +75,7 @@ export declare const BasketLineSchema: z.ZodObject<{
|
|
|
75
75
|
unitPrice: z.ZodNumber;
|
|
76
76
|
href: z.ZodOptional<z.ZodString>;
|
|
77
77
|
image: z.ZodOptional<z.ZodString>;
|
|
78
|
+
offerId: z.ZodOptional<z.ZodString>;
|
|
78
79
|
}, z.core.$strip>;
|
|
79
80
|
export type BasketLine = z.infer<typeof BasketLineSchema>;
|
|
80
81
|
/**
|
|
@@ -106,6 +107,7 @@ export declare const BasketSchema: z.ZodObject<{
|
|
|
106
107
|
unitPrice: z.ZodNumber;
|
|
107
108
|
href: z.ZodOptional<z.ZodString>;
|
|
108
109
|
image: z.ZodOptional<z.ZodString>;
|
|
110
|
+
offerId: z.ZodOptional<z.ZodString>;
|
|
109
111
|
}, z.core.$strip>>;
|
|
110
112
|
}, z.core.$strip>;
|
|
111
113
|
export type Basket = z.infer<typeof BasketSchema>;
|
package/dist/domain.js
CHANGED
|
@@ -31,6 +31,11 @@ export const BasketLineSchema = z.object({
|
|
|
31
31
|
unitPrice: z.number().finite().nonnegative(),
|
|
32
32
|
href: z.string().min(1).optional(),
|
|
33
33
|
image: z.string().min(1).optional(),
|
|
34
|
+
/**
|
|
35
|
+
* The offer the shopper chose for this line, when they picked a tier. The
|
|
36
|
+
* server still applies it only if it holds for the quantity.
|
|
37
|
+
*/
|
|
38
|
+
offerId: z.string().min(1).max(200).optional(),
|
|
34
39
|
});
|
|
35
40
|
/**
|
|
36
41
|
* The server-facing projection of a basket line. UI-only fields are omitted,
|
package/package.json
CHANGED