@zeyolabs/shopping 2026.11.34 → 2026.11.36

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/config.ts CHANGED
@@ -64,6 +64,9 @@ export type CheckoutOptions = {
64
64
  promotionCodes?: boolean;
65
65
  };
66
66
 
67
+ /** Who the shop is and where it lives: what the emails need to name and link to it. */
68
+ export type ShopSite = Pick<ShoppingConfig, 'brand' | 'siteUrl'>;
69
+
67
70
  /** Everything that differs between sites. The package holds no brand, address or account of its own. */
68
71
  export type ShoppingConfig = {
69
72
  brand: EmailBrand;
@@ -1,6 +1,7 @@
1
1
  import type { EmailParams } from '@zeyolabs/kit/utils/email';
2
2
 
3
- import { shopping } from '../config';
3
+ import type { ShopSite } from '../config';
4
+
4
5
  import { Orders } from '../orders/library';
5
6
 
6
7
  export type DispatchEmailData = {
@@ -22,16 +23,16 @@ export type DispatchEmailData = {
22
23
  /** The dispatch email, as kit email params. */
23
24
  export const DispatchEmail = {
24
25
  /** Sent when the order leaves the shop: where it is, and how to follow it. */
25
- build(order: DispatchEmailData): EmailParams {
26
+ build(order: DispatchEmailData, site: ShopSite): EmailParams {
26
27
  const firstName = order.address.name.split(' ')[0] || 'there';
27
28
  const tracked = Boolean(order.trackingNumber);
28
29
  return {
29
30
  badge: 'Dispatched',
30
- brand: shopping().brand,
31
+ brand: site.brand,
31
32
  cta: tracked
32
33
  ? { href: Orders.trackingUrl(order.trackingNumber!), label: 'Track your parcel' }
33
34
  : {
34
- href: Orders.url(shopping().siteUrl, order.number, order.token),
35
+ href: Orders.url(site.siteUrl, order.number, order.token),
35
36
  label: 'View your order',
36
37
  },
37
38
  eyebrow: `Order ${order.number}`,
@@ -43,11 +44,11 @@ export const DispatchEmail = {
43
44
  `Your order ${order.number} has been dispatched by Royal Mail. UK orders usually arrive 2 to 10 working days after dispatch.`,
44
45
  ...(tracked
45
46
  ? [
46
- `You can also see it any time on your order page: ${Orders.url(shopping().siteUrl, order.number, order.token)}`,
47
+ `You can also see it any time on your order page: ${Orders.url(site.siteUrl, order.number, order.token)}`,
47
48
  ]
48
49
  : []),
49
50
  ],
50
- preheader: `Order ${order.number} has been dispatched. Thank you for shopping with ${shopping().brand.name}.`,
51
+ preheader: `Order ${order.number} has been dispatched. Thank you for shopping with ${site.brand.name}.`,
51
52
  sections: [
52
53
  {
53
54
  lines: [
package/mail/default.ts CHANGED
@@ -31,8 +31,9 @@ export function defaultShopMail({
31
31
  }): ShopMail {
32
32
  return {
33
33
  backInStock: async (alert) => {
34
- const { brand } = shopping();
35
- const email = BackInStockEmail.build(alert);
34
+ const site = shopping();
35
+ const { brand } = site;
36
+ const email = BackInStockEmail.build(alert, site);
36
37
  await send({
37
38
  from: { email: brand.supportEmail, name: brand.name },
38
39
  html: renderEmail(email),
@@ -42,8 +43,9 @@ export function defaultShopMail({
42
43
  });
43
44
  },
44
45
  newOrderAlert: async (order) => {
45
- const { brand } = shopping();
46
- const email = OrderEmails.shop(order);
46
+ const site = shopping();
47
+ const { brand } = site;
48
+ const email = OrderEmails.shop(order, site);
47
49
  await send({
48
50
  from: { email: brand.supportEmail, name: `${brand.name} website` },
49
51
  html: renderEmail(email),
@@ -54,8 +56,9 @@ export function defaultShopMail({
54
56
  });
55
57
  },
56
58
  orderConfirmed: async (order) => {
57
- const { brand } = shopping();
58
- const email = OrderEmails.customer(order);
59
+ const site = shopping();
60
+ const { brand } = site;
61
+ const email = OrderEmails.customer(order, site);
59
62
  await send({
60
63
  from: { email: brand.supportEmail, name: brand.name },
61
64
  html: renderEmail(email),
@@ -65,8 +68,9 @@ export function defaultShopMail({
65
68
  });
66
69
  },
67
70
  orderDispatched: async (order) => {
68
- const { brand } = shopping();
69
- const email = DispatchEmail.build(order);
71
+ const site = shopping();
72
+ const { brand } = site;
73
+ const email = DispatchEmail.build(order, site);
70
74
  await send({
71
75
  from: { email: brand.supportEmail, name: brand.name },
72
76
  html: renderEmail(email),
package/orders/email.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import type { EmailParams, EmailRow } from '@zeyolabs/kit/utils/email';
2
2
 
3
- import { shopping } from '../config';
3
+ import type { ShopSite } from '../config';
4
+
4
5
  import { Money } from '../utils/money';
5
6
 
6
7
  export type OrderEmailData = {
@@ -63,14 +64,14 @@ function totalRows(order: OrderEmailData): EmailRow[] {
63
64
  /** The order emails, as kit email params (the shop renders and sends them). */
64
65
  export const OrderEmails = {
65
66
  /** What the customer receives once payment has gone through. */
66
- customer(order: OrderEmailData): EmailParams {
67
+ customer(order: OrderEmailData, site: ShopSite): EmailParams {
67
68
  const firstName = order.address.name.split(' ')[0] || 'there';
68
69
  return {
69
70
  badge: 'Paid',
70
- brand: shopping().brand,
71
+ brand: site.brand,
71
72
  cta: order.orderUrl
72
73
  ? { href: order.orderUrl, label: 'View your order' }
73
- : { href: `${shopping().siteUrl}/shipping`, label: 'Delivery and returns' },
74
+ : { href: `${site.siteUrl}/shipping`, label: 'Delivery and returns' },
74
75
  eyebrow: `Order ${order.number}`,
75
76
  footnote: `Keep this email as your receipt. Quote ${order.number} if you contact us.${order.orderUrl ? ' Your order link is private to you, so please do not share it.' : ''}`,
76
77
  heading: `Thank you, ${firstName}`,
@@ -81,7 +82,7 @@ export const OrderEmails = {
81
82
  ? ['Use the link below to see when it is dispatched and to track it.']
82
83
  : []),
83
84
  ],
84
- preheader: `Order ${order.number} is confirmed. Thank you for shopping with ${shopping().brand.name}.`,
85
+ preheader: `Order ${order.number} is confirmed. Thank you for shopping with ${site.brand.name}.`,
85
86
  sections: [
86
87
  { rows: itemRows(order), title: 'Your order' },
87
88
  { rows: totalRows(order) },
@@ -91,10 +92,10 @@ export const OrderEmails = {
91
92
  },
92
93
 
93
94
  /** The internal heads-up to the shop: who ordered what, and where it goes. */
94
- shop(order: OrderEmailData): EmailParams {
95
+ shop(order: OrderEmailData, site: ShopSite): EmailParams {
95
96
  return {
96
97
  badge: 'Paid',
97
- brand: shopping().brand,
98
+ brand: site.brand,
98
99
  eyebrow: 'New order',
99
100
  heading: `${order.number}: ${Money.format(order.totalPence)}`,
100
101
  intro: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeyolabs/shopping",
3
- "version": "2026.11.34",
3
+ "version": "2026.11.36",
4
4
  "description": "Shop and order fulfilment for SvelteKit 3 on Cloudflare: catalogue, basket, Stripe Checkout, orders, Royal Mail Click & Drop, order emails, packing, pages and admin.",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
@@ -67,7 +67,7 @@
67
67
  "@eslint/compat": "2.1.1",
68
68
  "@eslint/js": "10.0.1",
69
69
  "@sveltejs/kit": "3.2.0",
70
- "@zeyolabs/kit": "2026.11.33",
70
+ "@zeyolabs/kit": "2026.11.34",
71
71
  "@zeyolabs/ui": "2026.1106.0",
72
72
  "drizzle-orm": "0.45.4",
73
73
  "eslint": "10.15.0",
@@ -1,6 +1,7 @@
1
1
  import type { EmailParams } from '@zeyolabs/kit/utils/email';
2
2
 
3
- import { shopping } from '../config';
3
+ import type { ShopSite } from '../config';
4
+
4
5
  import { Money } from '../utils/money';
5
6
 
6
7
  export type BackInStockEmailData = {
@@ -11,7 +12,7 @@ export type BackInStockEmailData = {
11
12
  };
12
13
 
13
14
  /** The product page the customer lands on from the email. */
14
- const productUrl = (slug: string): string => `${shopping().siteUrl}/product/${slug}`;
15
+ const productUrl = (siteUrl: string, slug: string): string => `${siteUrl}/product/${slug}`;
15
16
 
16
17
  /** The back-in-stock email, as kit email params. */
17
18
  export const BackInStockEmail = {
@@ -19,9 +20,8 @@ export const BackInStockEmail = {
19
20
  productUrl,
20
21
 
21
22
  /** Sent once to each customer who asked to be told when a sold-out product is back. */
22
- build(data: BackInStockEmailData): EmailParams {
23
- const { brand } = shopping();
24
- const url = productUrl(data.slug);
23
+ build(data: BackInStockEmailData, { brand, siteUrl }: ShopSite): EmailParams {
24
+ const url = productUrl(siteUrl, data.slug);
25
25
  return {
26
26
  badge: 'Back in stock',
27
27
  brand,