@revenexx/cover 0.2.37 → 0.2.38

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@revenexx/cover",
3
- "version": "0.2.37",
3
+ "version": "0.2.38",
4
4
  "description": "Cover \u2014 revenexx design system for Nuxt. Distributed as a Nuxt layer: generic UI components, theming tokens and stores shared by the demo shop, custom storefronts and the Blokkli theme.",
5
5
  "type": "module",
6
6
  "main": "./nuxt.config.ts",
@@ -14,6 +14,7 @@ async function resolveLiveOverrides(
14
14
  event: H3Event,
15
15
  body: CartCalculationRequest,
16
16
  subtotal: number,
17
+ cartCurrency: string,
17
18
  ): Promise<CartCalculationOverrides> {
18
19
  const overrides: CartCalculationOverrides = {};
19
20
  const currency = resolveSelectedCurrency(event);
@@ -60,8 +61,12 @@ async function resolveLiveOverrides(
60
61
  // Promotions run AFTER prices: the engine reduces prices and refuses a line
61
62
  // that has none, so it needs the resolved ones. It writes nothing, which is
62
63
  // why the storefront may call it on every keystroke.
64
+ // The promotions contract requires a currency, and a single-currency
65
+ // storefront never sets the currency cookie — so fall back to the cart's
66
+ // own, or every evaluation is refused and the cart quietly shows no
67
+ // discount at all.
63
68
  const promo = await evaluatePromotions(event, {
64
- currency,
69
+ currency: currency ?? cartCurrency,
65
70
  codes: body.voucherCodes,
66
71
  lines: body.items.map((it, index) => ({
67
72
  // 1-based, the same numbering the order sends when it asks the very
@@ -145,7 +150,7 @@ export default defineEventHandler(async (event) => {
145
150
  return base;
146
151
  }
147
152
  const subtotal = base.totals.find(row => row.key === "subtotal")?.amount ?? 0;
148
- const overrides = await resolveLiveOverrides(event, body, subtotal);
153
+ const overrides = await resolveLiveOverrides(event, body, subtotal, base.currency);
149
154
  if (!overrides.shipping && !overrides.itemTaxRates && !overrides.itemUnitPrices
150
155
  && !overrides.currency && !overrides.promotion) {
151
156
  return base;
@@ -86,7 +86,7 @@ export async function evaluatePromotions(
86
86
  totals?: { discount_total?: number };
87
87
  applied?: Array<Record<string, unknown>>;
88
88
  rejected_codes?: string[];
89
- }>("POST", "/promotions/evaluate", {
89
+ }>("POST", "/v1/promotions/evaluate", {
90
90
  body: {
91
91
  currency: input.currency,
92
92
  lines: input.lines,
@@ -191,7 +191,7 @@ export async function reserveRedemption(
191
191
  return "not_applicable";
192
192
  }
193
193
  try {
194
- await useRevenexxSdk().call("POST", "/promotions/reserve", {
194
+ await useRevenexxSdk().call("POST", "/v1/promotions/reserve", {
195
195
  body: {
196
196
  cart_id: input.cartId,
197
197
  promotions,
@@ -235,7 +235,7 @@ export async function commitRedemption(
235
235
  return;
236
236
  }
237
237
  try {
238
- await useRevenexxSdk().call("POST", "/promotions/commit", {
238
+ await useRevenexxSdk().call("POST", "/v1/promotions/commit", {
239
239
  body: {
240
240
  order_id: input.orderId,
241
241
  // Commit promotes the cart's held rows; the list is what it falls
@@ -265,7 +265,7 @@ export async function releaseRedemption(
265
265
  return;
266
266
  }
267
267
  try {
268
- await useRevenexxSdk().call("POST", "/promotions/release", {
268
+ await useRevenexxSdk().call("POST", "/v1/promotions/release", {
269
269
  body: { cart_id: input.cartId, reason: input.reason },
270
270
  });
271
271
  }