@growth-labs/store 0.3.1 → 0.3.3

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 ADDED
@@ -0,0 +1,16 @@
1
+ # Changelog
2
+
3
+ ## 0.3.3
4
+
5
+ - Restore the product-detail related-products shelf using each site's curated
6
+ collection order, with the main catalogue as a best-effort fallback.
7
+ - Keep one primary purchase action on product pages instead of stacking
8
+ equally prominent Add to cart and Buy now buttons.
9
+ - Restore the compact secure-checkout label, payment badges, and Fourthwall
10
+ fulfillment note beneath the purchase action.
11
+
12
+ ## 0.3.2
13
+
14
+ - Export `@growth-labs/store/tailwind.css` so Tailwind CSS 4 consumers can
15
+ register the package's Astro components and generate every storefront
16
+ utility class.
package/README.md CHANGED
@@ -5,12 +5,26 @@ Storefront API client, browser cart, checkout/webhook routes, and page-body
5
5
  components. See [`packages-docs/store.md`](../../packages-docs/store.md) for
6
6
  the full contract, config shape, and adoption notes.
7
7
 
8
+ `StoreProductPage` includes one primary Add to cart action and a best-effort
9
+ three-item related-products shelf. It prefers the first configured division
10
+ or type collection containing the current product, then falls back to the
11
+ main catalogue. The purchase block also shows the shared payment badges and
12
+ compact Fourthwall checkout/fulfillment disclosure used by channel sites.
13
+
8
14
  ## Install
9
15
 
10
16
  ```sh
11
17
  pnpm add @growth-labs/store
12
18
  ```
13
19
 
20
+ Register the package's Astro components with Tailwind CSS 4 from the site's
21
+ global stylesheet:
22
+
23
+ ```css
24
+ @import "tailwindcss";
25
+ @import "@growth-labs/store/tailwind.css";
26
+ ```
27
+
14
28
  ## Quick start
15
29
 
16
30
  ```ts
package/dist/index.d.ts CHANGED
@@ -19,6 +19,8 @@ export { storeOptionsSchema } from './options.js';
19
19
  export type { OrderTelemetryOptions } from './orders.js';
20
20
  export { buildStoreOrderWAEDataPoint, createD1OrderHandler } from './orders.js';
21
21
  export { resolveStoreProduct } from './products.js';
22
+ export type { RelatedCollectionProducts, RelatedProductsResult } from './related.js';
23
+ export { chooseRelatedCollection } from './related.js';
22
24
  /**
23
25
  * `getConfig`/`getConfigOrNull` resolve this site's fully-parsed `StoreOptions`
24
26
  * at runtime — the same mechanism `.astro` page components use internally
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAE7C,OAAO,EAAE,KAAK,YAAY,EAAsB,MAAM,cAAc,CAAA;AAepE,MAAM,CAAC,OAAO,UAAU,KAAK,CAAC,WAAW,EAAE,YAAY,GAAG,gBAAgB,CAyCzE;AAED,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAC3E,OAAO,EAAE,2BAA2B,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAClG,YAAY,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAA;AAC7F,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAA;AACjE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC/F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACpD,YAAY,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;AACpD,YAAY,EACX,eAAe,EACf,uBAAuB,EACvB,uBAAuB,GACvB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACN,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,sBAAsB,GACtB,MAAM,kBAAkB,CAAA;AACzB,YAAY,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAA;A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sB,EAAE,MAAM,cAAc,CAAA;AAChF,OAAO,EACN,uBAAuB,EACvB,2BAA2B,EAC3B,qCAAqC,EACrC,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,GAClB,MAAM,cAAc,CAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { fileURLToPath } from 'node:url';
1
+ import { fileURLToPath, URL } from 'node:url';
2
2
  import { setOrderPlacedHandler } from './api.js';
3
3
  import { storeOptionsSchema } from './options.js';
4
4
  import { createD1OrderHandler } from './orders.js';
@@ -58,6 +58,7 @@ export { hasProductImages, optimizeFwImage } from './image.js';
58
58
  export { storeOptionsSchema } from './options.js';
59
59
  export { buildStoreOrderWAEDataPoint, createD1OrderHandler } from './orders.js';
60
60
  export { resolveStoreProduct } from './products.js';
61
+ export { chooseRelatedCollection } from './related.js';
61
62
  /**
62
63
  * `getConfig`/`getConfigOrNull` resolve this site's fully-parsed `StoreOptions`
63
64
  * at runtime — the same mechanism `.astro` page components use internally
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAChD,OAAO,EAAqB,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAExD,SAAS,kBAAkB;IAC1B,OAAO,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;AAC9E,CAAC;AAED,MAAM,oBAAoB,GAAG,kBAAkB,EAAE,CAAC,CAA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;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAEnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AACtD;;;;;;;;;GASG;AACH,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEvD;;;;;;;GAOG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,EACN,uBAAuB,EACvB,2BAA2B,EAC3B,qCAAqC,EACrC,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,GAClB,MAAM,cAAc,CAAA"}
@@ -0,0 +1,18 @@
1
+ import type { StoreCollection } from './collections.js';
2
+ import type { FwProduct } from './types.js';
3
+ export interface RelatedCollectionProducts {
4
+ collection: Pick<StoreCollection, 'handle' | 'name'>;
5
+ results: FwProduct[];
6
+ }
7
+ export interface RelatedProductsResult {
8
+ collectionName: string;
9
+ products: FwProduct[];
10
+ }
11
+ /**
12
+ * Pick the first curated collection that contains the current product and
13
+ * return up to three other products from it. Candidate order is meaningful:
14
+ * consumers put their most specific branded collections before broad product
15
+ * types, so the shelf keeps the strongest merchandising context available.
16
+ */
17
+ export declare function chooseRelatedCollection(productSlug: string, collectionResults: RelatedCollectionProducts[], limit?: number): RelatedProductsResult;
18
+ //# sourceMappingURL=related.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"related.d.ts","sourceRoot":"","sources":["../src/related.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,MAAM,WAAW,yBAAyB;IACzC,UAAU,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,MAAM,CAAC,CAAA;IACpD,OAAO,EAAE,SAAS,EAAE,CAAA;CACpB;AAED,MAAM,WAAW,qBAAqB;IACrC,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,SAAS,EAAE,CAAA;CACrB;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACtC,WAAW,EAAE,MAAM,EACnB,iBAAiB,EAAE,yBAAyB,EAAE,EAC9C,KAAK,SAAI,GACP,qBAAqB,CAWvB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Pick the first curated collection that contains the current product and
3
+ * return up to three other products from it. Candidate order is meaningful:
4
+ * consumers put their most specific branded collections before broad product
5
+ * types, so the shelf keeps the strongest merchandising context available.
6
+ */
7
+ export function chooseRelatedCollection(productSlug, collectionResults, limit = 3) {
8
+ for (const { collection, results } of collectionResults) {
9
+ if (!results.some((product) => product.slug === productSlug))
10
+ continue;
11
+ const products = results.filter((product) => product.slug !== productSlug).slice(0, limit);
12
+ if (products.length > 0) {
13
+ return { collectionName: collection.name, products };
14
+ }
15
+ }
16
+ return { collectionName: '', products: [] };
17
+ }
18
+ //# sourceMappingURL=related.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"related.js","sourceRoot":"","sources":["../src/related.ts"],"names":[],"mappings":"AAaA;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACtC,WAAmB,EACnB,iBAA8C,EAC9C,KAAK,GAAG,CAAC;IAET,KAAK,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,iBAAiB,EAAE,CAAC;QACzD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC;YAAE,SAAQ;QAEtE,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;QAC1F,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACzB,OAAO,EAAE,cAAc,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAA;QACrD,CAAC;IACF,CAAC;IAED,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAA;AAC5C,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@growth-labs/store",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -17,6 +17,7 @@
17
17
  "import": "./dist/health.js"
18
18
  },
19
19
  "./components/*": "./src/components/*",
20
+ "./tailwind.css": "./tailwind.css",
20
21
  "./routes/*": {
21
22
  "types": "./dist/routes/*.d.ts",
22
23
  "import": "./dist/routes/*.js",
@@ -31,6 +32,7 @@
31
32
  "dist",
32
33
  "src/**/*.ts",
33
34
  "src/**/*.astro",
35
+ "tailwind.css",
34
36
  "migrations",
35
37
  "README.md",
36
38
  "CHANGELOG.md"
@@ -47,6 +49,7 @@
47
49
  },
48
50
  "devDependencies": {
49
51
  "astro": "7.3.1",
52
+ "tailwindcss": "4.3.3",
50
53
  "typescript": "^5.7.0",
51
54
  "vite": "8.0.16",
52
55
  "vitest": "^4.1.8"
@@ -9,6 +9,12 @@
9
9
  */
10
10
  import { getConfig } from '../state.js'
11
11
 
12
+ interface Props {
13
+ /** Hide the text payment-method list when the surrounding purchase block already shows payment badges. */
14
+ showPaymentMethods?: boolean
15
+ }
16
+
17
+ const { showPaymentMethods = true } = Astro.props
12
18
  const config = await getConfig()
13
19
  const legal = config.legal
14
20
  const hasIdentity = Boolean(legal.operator || legal.address)
@@ -19,7 +25,7 @@ const links: Array<{ href: string; label: string }> = [
19
25
  legal.contactPath ? { href: legal.contactPath, label: 'Contact' } : null,
20
26
  ].filter((link): link is { href: string; label: string } => link !== null)
21
27
 
22
- const hasContent = hasIdentity || links.length > 0 || Boolean(legal.paymentMethods?.length)
28
+ const hasContent = hasIdentity || links.length > 0 || (showPaymentMethods && Boolean(legal.paymentMethods?.length))
23
29
  ---
24
30
 
25
31
  {
@@ -44,7 +50,7 @@ const hasContent = hasIdentity || links.length > 0 || Boolean(legal.paymentMetho
44
50
  ))}
45
51
  </nav>
46
52
  )}
47
- {legal.paymentMethods && legal.paymentMethods.length > 0 && <p>Payment methods: {legal.paymentMethods.join(', ')}</p>}
53
+ {showPaymentMethods && legal.paymentMethods && legal.paymentMethods.length > 0 && <p>Payment methods: {legal.paymentMethods.join(', ')}</p>}
48
54
  </footer>
49
55
  )
50
56
  }
@@ -2,8 +2,10 @@
2
2
  import { env as cloudflareEnv } from 'cloudflare:workers'
3
3
  import { cachedJson, purgeProductCache } from '../cache.js'
4
4
  import { createFourthwallClient } from '../client.js'
5
+ import { getGroupedCollections, resolveShopCollections } from '../collections.js'
5
6
  import { getConfig } from '../state.js'
6
7
  import { hasProductImages, optimizeFwImage } from '../image.js'
8
+ import { chooseRelatedCollection } from '../related.js'
7
9
  import { FourthwallError, type FwProduct } from '../types.js'
8
10
  import {
9
11
  buildStoreProductJsonLd,
@@ -13,6 +15,7 @@ import {
13
15
  } from '../variant.js'
14
16
  import AddToCartButton from './AddToCartButton.astro'
15
17
  import Price from './Price.astro'
18
+ import ProductCard from './ProductCard.astro'
16
19
  import StoreLegalFooter from './StoreLegalFooter.astro'
17
20
  import VariantPicker from './VariantPicker.astro'
18
21
 
@@ -42,14 +45,14 @@ const env = cloudflareEnv as FwEnv
42
45
  const token = env?.PUBLIC_FW_STOREFRONT_TOKEN ?? ''
43
46
  const cookieCurrency = Astro.cookies.get('fw_currency')?.value
44
47
  const currency = cookieCurrency && config.supportedCurrencies.includes(cookieCurrency) ? cookieCurrency : config.defaultCurrency
48
+ const client = token ? createFourthwallClient({ token, defaultCurrency: currency }) : null
45
49
 
46
50
  let product: FwProduct | null = null
47
51
  let errorMessage: string | null = null
48
52
 
49
- if (!token) {
53
+ if (!client) {
50
54
  if (config.checkoutEnabled) errorMessage = "Store isn't configured yet."
51
55
  } else {
52
- const client = createFourthwallClient({ token, defaultCurrency: currency })
53
56
  try {
54
57
  product = await cachedJson({
55
58
  pathSegment: `/products/${encodeURIComponent(slug)}`,
@@ -136,6 +139,57 @@ const initialGallery = variantImagesMap[initialVariantId] ?? productLevelImages
136
139
  const heroImage = initialGallery[0]
137
140
  const descriptionHtml = product?.descriptionHtml ?? product?.description ?? ''
138
141
 
142
+ // Restore the merchandising shelf every pre-package storefront carried:
143
+ // prefer the first curated collection that contains this product, then fall
144
+ // back to the main catalogue. All lookups are best-effort so recommendations
145
+ // can never make the product itself unavailable.
146
+ let relatedProducts: FwProduct[] = []
147
+ let relatedCollectionName = ''
148
+ if (product && client) {
149
+ try {
150
+ const collections = await resolveShopCollections({ client, overrides: config.collections })
151
+ const candidateCollections = [
152
+ ...getGroupedCollections(collections, 'division'),
153
+ ...getGroupedCollections(collections, 'type'),
154
+ ].filter((collection) => collection.handle !== config.catalogueHandle)
155
+ const collectionResults = await Promise.allSettled(
156
+ candidateCollections.map((collection) =>
157
+ cachedJson({
158
+ pathSegment: `/collections/${encodeURIComponent(collection.handle)}/products`,
159
+ query: { cur: currency, preview: 'related' },
160
+ ttlSeconds: 600,
161
+ fetcher: () => client.getCollectionProducts({ handle: collection.handle, currency, size: 50 }),
162
+ }).then((data) => ({ collection, results: data.results })),
163
+ ),
164
+ )
165
+ const related = chooseRelatedCollection(
166
+ product.slug,
167
+ collectionResults
168
+ .filter((result) => result.status === 'fulfilled')
169
+ .map((result) => result.value),
170
+ )
171
+ relatedProducts = related.products
172
+ relatedCollectionName = related.collectionName
173
+ } catch {
174
+ // The catalogue fallback below still has a chance to populate the shelf.
175
+ }
176
+
177
+ if (relatedProducts.length === 0) {
178
+ try {
179
+ const result = await cachedJson({
180
+ pathSegment: `/collections/${encodeURIComponent(config.catalogueHandle)}/products`,
181
+ query: { cur: currency, preview: 'related-fallback' },
182
+ ttlSeconds: 600,
183
+ fetcher: () => client.getCollectionProducts({ handle: config.catalogueHandle, currency, size: 50 }),
184
+ })
185
+ relatedProducts = result.results.filter((candidate) => candidate.slug !== product.slug).slice(0, 3)
186
+ relatedCollectionName = 'The store'
187
+ } catch {
188
+ // Product detail remains fully usable when recommendations are unavailable.
189
+ }
190
+ }
191
+ }
192
+
139
193
  const jsonLd =
140
194
  product && selectedVariant
141
195
  ? buildStoreProductJsonLd({
@@ -260,15 +314,52 @@ const fourthwallProductUrl = fourthwallShopBaseUrl && product ? `${fourthwallSho
260
314
  checkoutPath={config.routes.checkoutPath}
261
315
  fourthwallProductUrl={fourthwallProductUrl}
262
316
  />
263
- <AddToCartButton
264
- firstVariantId={selectedVariant.id}
265
- initialAvailable={isStoreVariantAvailable(selectedVariant)}
266
- pickerSelector="[data-variant-picker]"
267
- mode="buy-now"
268
- checkoutPath={config.routes.checkoutPath}
269
- />
270
- {(config.legal.returnsPath || config.legal.shippingPath) && (
271
- <p class="text-sm text-[var(--muted-foreground)]">
317
+ <div class="space-y-3 border-t border-[var(--border)] pt-3">
318
+ <p class="flex items-center gap-2 text-xs font-semibold uppercase tracking-[0.14em] text-[var(--muted-foreground)]">
319
+ <svg
320
+ class="h-3 w-3 shrink-0"
321
+ viewBox="0 0 24 24"
322
+ fill="none"
323
+ stroke="currentColor"
324
+ stroke-width="2"
325
+ stroke-linecap="round"
326
+ stroke-linejoin="round"
327
+ aria-hidden="true"
328
+ >
329
+ <rect x="4" y="11" width="16" height="9" rx="1" />
330
+ <path d="M8 11V7a4 4 0 0 1 8 0v4" />
331
+ </svg>
332
+ Secure checkout through Fourthwall
333
+ </p>
334
+ <div class="flex flex-wrap items-center gap-3">
335
+ {[
336
+ { src: '/images/payment/apple-pay.svg', alt: 'Apple Pay', class: 'h-8 w-auto', width: 64, height: 32 },
337
+ { src: '/images/payment/google-pay.svg', alt: 'Google Pay', class: 'h-8 w-auto', width: 64, height: 32 },
338
+ { src: '/images/payment/paypal.svg', alt: 'PayPal', class: 'h-5 w-auto', width: 80, height: 20 },
339
+ { src: '/images/payment/visa.svg', alt: 'Visa', class: 'h-6 w-auto', width: 38, height: 24 },
340
+ { src: '/images/payment/mastercard.svg', alt: 'Mastercard', class: 'h-6 w-auto', width: 38, height: 24 },
341
+ { src: '/images/payment/amex.svg', alt: 'American Express', class: 'h-6 w-auto', width: 38, height: 24 },
342
+ ].map((badge) => (
343
+ <img
344
+ src={badge.src}
345
+ alt={badge.alt}
346
+ class={badge.class}
347
+ width={badge.width}
348
+ height={badge.height}
349
+ loading="lazy"
350
+ decoding="async"
351
+ />
352
+ ))}
353
+ </div>
354
+ </div>
355
+ <p class="text-xs leading-relaxed text-[var(--muted-foreground)]">
356
+ Made to order. Production and delivery times vary by item and destination.
357
+ </p>
358
+ <p class="text-xs leading-relaxed text-[var(--muted-foreground)]">
359
+ Sold and fulfilled by Fourthwall.
360
+ {(config.legal.returnsPath || config.legal.shippingPath) && (
361
+ <>
362
+ {' '}
272
363
  {config.legal.shippingPath && (
273
364
  <a href={config.legal.shippingPath} class="underline-offset-4 hover:underline">
274
365
  Shipping
@@ -280,8 +371,9 @@ const fourthwallProductUrl = fourthwallShopBaseUrl && product ? `${fourthwallSho
280
371
  returns
281
372
  </a>
282
373
  )}
283
- </p>
374
+ </>
284
375
  )}
376
+ </p>
285
377
  </div>
286
378
  )}
287
379
  {selectedVariant && !config.checkoutEnabled && (
@@ -291,7 +383,27 @@ const fourthwallProductUrl = fourthwallShopBaseUrl && product ? `${fourthwallSho
291
383
  </div>
292
384
  )}
293
385
 
294
- <StoreLegalFooter />
386
+ {product && relatedProducts.length > 0 && (
387
+ <section class="space-y-6 border-t border-[var(--border)] pt-12" aria-labelledby="store-related-heading">
388
+ <div>
389
+ <p class="text-xs uppercase tracking-[0.14em] text-[var(--muted-foreground)]">More from</p>
390
+ <h2 id="store-related-heading" class="mt-1 text-2xl font-semibold text-[var(--foreground)]">
391
+ {relatedCollectionName}
392
+ </h2>
393
+ </div>
394
+ <div class="grid grid-cols-1 gap-6 sm:grid-cols-3">
395
+ {relatedProducts.map((relatedProduct) => (
396
+ <ProductCard
397
+ product={relatedProduct}
398
+ imageTransformEnabled={config.imageTransform.enabled}
399
+ basePath={basePath}
400
+ />
401
+ ))}
402
+ </div>
403
+ </section>
404
+ )}
405
+
406
+ <StoreLegalFooter showPaymentMethods={false} />
295
407
 
296
408
  <script>
297
409
  document.querySelectorAll<HTMLElement>('[data-product-root]').forEach((root) => {
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { fileURLToPath } from 'node:url'
1
+ import { fileURLToPath, URL } from 'node:url'
2
2
  import type { AstroIntegration } from 'astro'
3
3
  import { setOrderPlacedHandler } from './api.js'
4
4
  import { type StoreOptions, storeOptionsSchema } from './options.js'
@@ -87,6 +87,8 @@ export { storeOptionsSchema } from './options.js'
87
87
  export type { OrderTelemetryOptions } from './orders.js'
88
88
  export { buildStoreOrderWAEDataPoint, createD1OrderHandler } from './orders.js'
89
89
  export { resolveStoreProduct } from './products.js'
90
+ export type { RelatedCollectionProducts, RelatedProductsResult } from './related.js'
91
+ export { chooseRelatedCollection } from './related.js'
90
92
  /**
91
93
  * `getConfig`/`getConfigOrNull` resolve this site's fully-parsed `StoreOptions`
92
94
  * at runtime — the same mechanism `.astro` page components use internally
package/src/related.ts ADDED
@@ -0,0 +1,35 @@
1
+ import type { StoreCollection } from './collections.js'
2
+ import type { FwProduct } from './types.js'
3
+
4
+ export interface RelatedCollectionProducts {
5
+ collection: Pick<StoreCollection, 'handle' | 'name'>
6
+ results: FwProduct[]
7
+ }
8
+
9
+ export interface RelatedProductsResult {
10
+ collectionName: string
11
+ products: FwProduct[]
12
+ }
13
+
14
+ /**
15
+ * Pick the first curated collection that contains the current product and
16
+ * return up to three other products from it. Candidate order is meaningful:
17
+ * consumers put their most specific branded collections before broad product
18
+ * types, so the shelf keeps the strongest merchandising context available.
19
+ */
20
+ export function chooseRelatedCollection(
21
+ productSlug: string,
22
+ collectionResults: RelatedCollectionProducts[],
23
+ limit = 3,
24
+ ): RelatedProductsResult {
25
+ for (const { collection, results } of collectionResults) {
26
+ if (!results.some((product) => product.slug === productSlug)) continue
27
+
28
+ const products = results.filter((product) => product.slug !== productSlug).slice(0, limit)
29
+ if (products.length > 0) {
30
+ return { collectionName: collection.name, products }
31
+ }
32
+ }
33
+
34
+ return { collectionName: '', products: [] }
35
+ }
package/tailwind.css ADDED
@@ -0,0 +1 @@
1
+ @source "./src/components";