@discount-depot/hydrogen 0.1.4 → 0.1.5

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/README.md CHANGED
@@ -334,4 +334,23 @@ automatic session integration.
334
334
  Version 0.1.3 fixes Oxygen runtime compatibility by using manual redirects and
335
335
  rejecting non-success responses. Customer credentials are never forwarded across
336
336
  redirects. The regression suite includes real workerd fetch tests for guest and
337
- logged-in PDP/batch requests.
337
+ logged-in PDP/batch requests.
338
+
339
+ ## Multi-currency previews (unreleased)
340
+
341
+ The backend can estimate monetary rules in the shopper's currency using a shared,
342
+ cached median of Shopify base/contextual variant price ratios. This is an estimate,
343
+ not Shopify's `presentmentCurrencyRate`. Fixed discounts, volume spend thresholds,
344
+ Cart Goal targets and BXGY fixed rewards/minimum spend use that factor. Percentage
345
+ values and quantity thresholds remain unchanged. Invalid or unavailable estimates
346
+ retain the existing cross-currency fallbacks.
347
+
348
+ The backend returns `estimated: true` as metadata on evaluated offers; all four
349
+ components display the offer without an additional estimate notice. No rate is
350
+ accepted from the browser, and no additional per-card request is needed. Existing
351
+ country/market/customer eligibility still applies. Keep the storefront country and
352
+ cart buyer identity synchronized. Shopify's actual cart amounts remain authoritative.
353
+
354
+ Deploy the matching backend and publish a new package version to distribute this
355
+ feature. Registry 0.1.4 alone does not preserve the estimate metadata. This development
356
+ storefront applies the matching patch using `patch-package` until that release.
@@ -1,5 +1,6 @@
1
1
  import { type DepotCountdown } from './countdown-data.js';
2
2
  export interface DepotBuyXGetYOffer {
3
+ estimated?: boolean;
3
4
  id: string;
4
5
  eligible: true;
5
6
  discountType: 'AUTOMATIC';
@@ -72,6 +72,7 @@ export function normalizeBuyXGetY(value, currency, allowCartActions = false) {
72
72
  offers.push({
73
73
  id: offer.id,
74
74
  eligible: true,
75
+ ...(offer.estimated === true ? { estimated: true } : {}),
75
76
  discountType: 'AUTOMATIC',
76
77
  currencyCode: currency,
77
78
  title: offer.title,
@@ -33,6 +33,7 @@ export interface GoalCart {
33
33
  }
34
34
  export declare function cartGoalKey(cart: GoalCart): string;
35
35
  export interface DepotCartGoal {
36
+ estimated?: boolean;
36
37
  eligible: true;
37
38
  discountType: 'AUTOMATIC';
38
39
  currencyCode: string;
@@ -50,6 +50,7 @@ export function normalizeCartGoal(value, currency) {
50
50
  }
51
51
  return {
52
52
  eligible: true,
53
+ ...(goal.estimated === true ? { estimated: true } : {}),
53
54
  discountType: 'AUTOMATIC',
54
55
  currencyCode: currency,
55
56
  targetAmount: goal.targetAmount,
package/dist/server.d.ts CHANGED
@@ -29,6 +29,7 @@ export interface DiscountInput {
29
29
  country: string;
30
30
  }
31
31
  export interface DepotDiscount {
32
+ estimated?: boolean;
32
33
  countdown?: DepotCountdown | null;
33
34
  eligible: boolean;
34
35
  originalPrice: string;
package/dist/server.js CHANGED
@@ -217,6 +217,7 @@ function normalizeDiscount(result, input, batch = false) {
217
217
  }
218
218
  return {
219
219
  eligible: true,
220
+ ...('estimated' in result && result.estimated === true ? { estimated: true } : {}),
220
221
  originalPrice: input.price,
221
222
  ...(!batch && 'countdown' in result
222
223
  ? { countdown: normalizeCountdown(result.countdown) } : {}),
package/dist/volume.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { type DepotCountdown } from './countdown-data.js';
2
2
  /** Public, evaluated preview data; never send raw database rules to the browser. */
3
3
  export interface DepotVolumeTable {
4
+ estimated?: boolean;
4
5
  eligible: true;
5
6
  discountType: 'AUTOMATIC' | 'CODE';
6
7
  discountCode?: string;
package/dist/volume.js CHANGED
@@ -69,6 +69,7 @@ export function normalizeVolumeTable(value, price) {
69
69
  }
70
70
  return {
71
71
  eligible: true,
72
+ ...(table.estimated === true ? { estimated: true } : {}),
72
73
  discountType: table.discountType,
73
74
  ...(table.discountType === 'CODE' ? { discountCode: table.showDiscountCode === false ? undefined : table.discountCode, showDiscountCode: table.showDiscountCode !== false } : {}),
74
75
  currencyCode: price.currencyCode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discount-depot/hydrogen",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Automatic discount previews for Shopify Hydrogen storefronts",
5
5
  "type": "module",
6
6
  "sideEffects": false,