Branchwell

Lumen & Gesso / website · lumengesso.com / app / lib / pricing.ts

Raw 20.4 KB on f4d070c0cd6547ed6432bda0f7f1dc2cb2181b18
1// Single source of truth for product catalogue, pricing, and frame
2// geometry. Imported by:
3// - Builder (display + preview mount geometry)
4// - /api/orders (Stripe charge amount via priceCents)
5// - Stripe webhook (Prodigi SKU + attribute payload)
6//
7// Sizes here are the real Prodigi catalogue sizes for the two SKU
8// families we ship:
9// - matted → FRA-BOX-EMA-MOUNT1-ACRY-{SIZE} (Box frame, 1.4mm mounted
10// EMA print, perspex glaze). Sizes
11// are METRIC (cm) in this SKU family
12// — `prodigiSize` carries the cm code
13// (e.g. 40X50) while `label` keeps the
14// nominal inch size the same physical
15// piece has always been sold under
16// (40×50cm === 16×20"). This product
17// fulfils a customer-chosen mountColor
18// (Snow white / Off-white / Black).
19// - canvas → GLOBAL-FRA-CAN-{SIZE}(Float-framed canvas on 38 mm
20// premium stretcher bars)
21// Frame finish is a Prodigi *variant attribute* (not part of the SKU),
22// passed in the order item as `attributes.color`. Canvas additionally
23// takes `attributes.wrap` — we default to ImageWrap.
24//
25// AT COST (Nov 2026): every product is sold at cost with no markup, and
26// the portrait artwork itself is made free. Each row's `price` is the
27// landed Prodigi cost (item + Budget shipping to the US) plus the Stripe
28// card fee (2.9% + 30¢), rounded up to the whole dollar. That is what the
29// customer pays and what Stripe charges. Rows with a no-mat variant carry
30// `nomatPrice` for that SKU. There is no list price, sale, or discount.
31// Sizes Prodigi doesn't fulfil to the US (e.g. FRA-BOX 8×10 / 20×25cm,
32// FRA-CAN 14×14) are intentionally omitted.
33
34export const PRODUCTS = {
35 matted: {
36 label: 'Box Frame Matted Print',
37 sub: 'Archival giclée, matted, in a real wood box frame.',
38 // Concrete materials spec — surfaced in the product card so
39 // customers see exactly what they're getting before they pay.
40 // Matches the Prodigi FRA-BOX-EMA-MOUNT1-ACRY (box frame, mounted)
41 // line, which fulfils a choice of mount colour.
42 specs: [
43 '200gsm Enhanced Matte Art (EMA) paper',
44 '1.4mm acid-free mount, in your choice of colour',
45 'Acrylic / Perspex glaze (shatter-resistant, UV-protective)',
46 'Real wood moulding, 20mm face',
47 ],
48 // Product photography. `hero` is the small image shown in the
49 // picker card; `photos` is the full set used by the lightbox so
50 // the customer can inspect frame depth, corner finish, and the
51 // available wood finishes before committing.
52 hero: '/products/boxframe-hero.jpg',
53 photos: [
54 { src: '/products/boxframe-hero.jpg', label: 'Portrait in box frame' },
55 { src: '/products/boxframe-depth.jpg', label: 'Frame depth' },
56 { src: '/products/boxframe-chevrons.jpg', label: 'Available wood finishes' },
57 ],
58 // Box frames ship in four finishes — matte black, soft white,
59 // walnut (rich brown), and honey oak. Gold and brushed silver
60 // aren't part of the box frame product line (they're canvas-only).
61 // availableFrames is enforced in Builder so the picker hides
62 // unavailable options and auto-snaps the current selection when
63 // switching products.
64 availableFrames: ['black', 'walnut', 'oak', 'white'] as const,
65 // Mount choices shown in the Builder for this product. Snow white /
66 // Off-white / Black fulfil on FRA-BOX-EMA-MOUNT1-ACRY; 'nomat' fulfils
67 // on the No-Mount sibling FRA-BOX-EMA-NM-ACRY (see prodigi-skus.ts).
68 availableMattes: ['snowwhite', 'offwhite', 'black', 'nomat'] as const,
69 // Box-frame moulding face = 20 mm, visibly thicker than the canvas
70 // float frame. The mat board sits inside the rebate; matteW is the
71 // face-width of the cream mat when mat is toggled on (customer can
72 // turn the mat off).
73 frameW: 18,
74 matteW: 60,
75 prodigiSkuPrefix: 'FRA-BOX-EMA-MOUNT1-ACRY',
76 // FRA-BOX is a METRIC catalogue: `prodigiSize` is the cm code Prodigi
77 // expects in the SKU suffix; `label` keeps the nominal inch size the
78 // same physical piece has always carried (40×50cm === 16×20", etc.).
79 // `price` = mounted (mat-board) at cost; `nomatPrice` = the No-Mount
80 // sibling FRA-BOX-EMA-NM-ACRY-<metric code>, also at cost.
81 sizes: {
82 '8x8': { label: '8 × 8 in', aspect: '1 / 1', prodigiSize: '20X20', price: 115, nomatPrice: 115 },
83 '11x14': { label: '11 × 14 in', aspect: '11 / 14', prodigiSize: '28X35', price: 140, nomatPrice: 140 },
84 '12x12': { label: '12 × 12 in', aspect: '1 / 1', prodigiSize: '30X30', price: 132, nomatPrice: 132 },
85 '12x16': { label: '12 × 16 in', aspect: '3 / 4', prodigiSize: '30X40', price: 148, nomatPrice: 140 },
86 '16x16': { label: '16 × 16 in', aspect: '1 / 1', prodigiSize: '40X40', price: 173, nomatPrice: 165 },
87 '16x20': { label: '16 × 20 in', aspect: '4 / 5', prodigiSize: '40X50', price: 198, nomatPrice: 189 },
88 '18x24': { label: '18 × 24 in', aspect: '3 / 4', prodigiSize: '45X60', price: 222, nomatPrice: 214 },
89 '20x20': { label: '20 × 20 in', aspect: '1 / 1', prodigiSize: '50X50', price: 214, nomatPrice: 206 },
90 '20x28': { label: '20 × 28 in', aspect: '5 / 7', prodigiSize: '50X70', price: 255, nomatPrice: 247 },
91 '24x24': { label: '24 × 24 in', aspect: '1 / 1', prodigiSize: '60X60', price: 239, nomatPrice: 231 },
92 },
93 defaultSize: '12x16',
94 },
95 classic: {
96 label: 'Classic Framed Print',
97 sub: 'Our bestselling framed giclée print — with or without a mount.',
98 // Prodigi's Classic Frame line (GLOBAL-CFP / -CFPM): solid
99 // satin-laminated wood, 20 mm face, Perspex glaze, EMA 200gsm fine
100 // art paper, orderable mounted (Snow white mat) or no-mat.
101 specs: [
102 '200gsm Enhanced Matte Art (EMA) fine art paper',
103 'Satin-laminated solid wood frame, 20mm face',
104 'Acrylic / Perspex glaze, delivered ready to hang',
105 'Optional 2.4mm acid-free mount, or no mat',
106 ],
107 hero: '/products/classic-hero-pet.png',
108 photos: [
109 { src: '/products/classic-hero-pet.png', label: 'Classic frame, mounted' },
110 { src: '/products/classic-flat-pet.png', label: 'Front view' },
111 { src: '/products/classic-corner-nomount-pet.png', label: 'Corner, no mount' },
112 { src: '/products/classic-far-corner-tan.png', label: 'Frame profile' },
113 { src: '/products/classic-back.jpg', label: 'Ready-to-hang back' },
114 ],
115 // Classic ships in all eight catalogue finishes.
116 availableFrames: ['black', 'white', 'walnut', 'oak', 'gold', 'silver', 'darkgrey', 'lightgrey'] as const,
117 // Mount choices: Snow white (the only mat colour Prodigi fulfils on
118 // the Classic Frame — CFPM is Snow-white-only) or 'nomat'. Mounted →
119 // GLOBAL-CFPM, no-mat → GLOBAL-CFP (see prodigi-skus.ts).
120 availableMattes: ['snowwhite', 'nomat'] as const,
121 // Slimmer than the box frame: 20 mm face, 22 mm depth from wall.
122 frameW: 13,
123 matteW: 50,
124 prodigiSkuPrefix: 'GLOBAL-CFPM',
125 // Classic Frame is INCH-coded (e.g. 16X20); our sizeIds match those
126 // inch codes, so `prodigiSize` carries the inch code verbatim.
127 // `price` = mounted (CFPM, Snow white) at cost; `nomatPrice` = no-mat
128 // (CFP) at cost. Only sizes present on BOTH CFP and CFPM are offered
129 // (14×14 and 24×30 are CFP-only, so omitted).
130 sizes: {
131 '8x8': { label: '8 × 8 in', aspect: '1 / 1', prodigiSize: '8X8', price: 58, nomatPrice: 58 },
132 '8x10': { label: '8 × 10 in', aspect: '4 / 5', prodigiSize: '8X10', price: 74, nomatPrice: 66 },
133 '11x14': { label: '11 × 14 in', aspect: '11 / 14', prodigiSize: '11X14', price: 74, nomatPrice: 66 },
134 '12x12': { label: '12 × 12 in', aspect: '1 / 1', prodigiSize: '12X12', price: 74, nomatPrice: 66 },
135 '12x16': { label: '12 × 16 in', aspect: '3 / 4', prodigiSize: '12X16', price: 82, nomatPrice: 74 },
136 '12x18': { label: '12 × 18 in', aspect: '2 / 3', prodigiSize: '12X18', price: 82, nomatPrice: 74 },
137 '16x16': { label: '16 × 16 in', aspect: '1 / 1', prodigiSize: '16X16', price: 82, nomatPrice: 74 },
138 '16x20': { label: '16 × 20 in', aspect: '4 / 5', prodigiSize: '16X20', price: 91, nomatPrice: 82 },
139 '18x24': { label: '18 × 24 in', aspect: '3 / 4', prodigiSize: '18X24', price: 91, nomatPrice: 91 },
140 '20x20': { label: '20 × 20 in', aspect: '1 / 1', prodigiSize: '20X20', price: 91, nomatPrice: 82 },
141 '20x28': { label: '20 × 28 in', aspect: '5 / 7', prodigiSize: '20X28', price: 107, nomatPrice: 99 },
142 '24x24': { label: '24 × 24 in', aspect: '1 / 1', prodigiSize: '24X24', price: 107, nomatPrice: 99 },
143 '30x30': { label: '30 × 30 in', aspect: '1 / 1', prodigiSize: '30X30', price: 140, nomatPrice: 124 },
144 '30x40': { label: '30 × 40 in', aspect: '3 / 4', prodigiSize: '30X40', price: 173, nomatPrice: 148 },
145 '40x40': { label: '40 × 40 in', aspect: '1 / 1', prodigiSize: '40X40', price: 198, nomatPrice: 198 },
146 },
147 defaultSize: '16x20',
148 },
149 canvas: {
150 label: 'Framed Canvas',
151 sub: 'Gallery-wrapped canvas in a thin wood float frame.',
152 specs: [
153 '400gsm Standard Canvas (SC), gallery-wrapped',
154 '12-colour archival inkjet print, ImageWrap edges',
155 '38mm premium pine stretcher bars',
156 'Thin wood float moulding, 12mm face, 5mm recess',
157 ],
158 hero: '/products/canvas-hero-golden.jpg',
159 photos: [
160 { src: '/products/canvas-hero-golden.jpg', label: 'Portrait in float frame' },
161 { src: '/products/canvas-depth.jpg', label: 'Side profile' },
162 { src: '/products/canvas-rear.jpg', label: 'Stretcher back' },
163 { src: '/products/canvas-chevrons.webp', label: 'Available wood finishes' },
164 ],
165 // Canvas float frames ship in the full six finishes. Prodigi's
166 // chevron photography currently only covers three (black / white /
167 // brown=walnut) — those three appear as detail photos in the
168 // product lightbox. The remaining three (oak, gold, silver) still
169 // ship; just not pictured yet.
170 availableFrames: ['black', 'white', 'walnut', 'oak', 'gold', 'silver'] as const,
171 // Float-frame moulding face = 12 mm and the canvas is recessed
172 // 5 mm inside the moulding. The mount renders the gap by reusing
173 // --matte-w with a dark --matte-bg so the recess reads as a shadow
174 // inset on all four sides — the visual signature of a float frame.
175 frameW: 10,
176 matteW: 4,
177 prodigiSkuPrefix: 'GLOBAL-FRA-CAN',
178 sizes: {
179 '8x10': { label: '8 × 10 in', aspect: '4 / 5', prodigiSize: '8X10', price: 74 },
180 '8x12': { label: '8 × 12 in', aspect: '2 / 3', prodigiSize: '8X12', price: 79 },
181 '10x10': { label: '10 × 10 in', aspect: '1 / 1', prodigiSize: '10X10', price: 79 },
182 '11x14': { label: '11 × 14 in', aspect: '11 / 14', prodigiSize: '11X14', price: 82 },
183 '12x12': { label: '12 × 12 in', aspect: '1 / 1', prodigiSize: '12X12', price: 82 },
184 '12x16': { label: '12 × 16 in', aspect: '3 / 4', prodigiSize: '12X16', price: 91 },
185 '12x18': { label: '12 × 18 in', aspect: '2 / 3', prodigiSize: '12X18', price: 96 },
186 '16x16': { label: '16 × 16 in', aspect: '1 / 1', prodigiSize: '16X16', price: 96 },
187 '16x20': { label: '16 × 20 in', aspect: '4 / 5', prodigiSize: '16X20', price: 112 },
188 '18x24': { label: '18 × 24 in', aspect: '3 / 4', prodigiSize: '18X24', price: 124 },
189 '20x20': { label: '20 × 20 in', aspect: '1 / 1', prodigiSize: '20X20', price: 120 },
190 '20x24': { label: '20 × 24 in', aspect: '5 / 6', prodigiSize: '20X24', price: 132 },
191 '20x28': { label: '20 × 28 in', aspect: '5 / 7', prodigiSize: '20X28', price: 145 },
192 '20x30': { label: '20 × 30 in', aspect: '2 / 3', prodigiSize: '20X30', price: 148 },
193 '24x24': { label: '24 × 24 in', aspect: '1 / 1', prodigiSize: '24X24', price: 140 },
194 '24x30': { label: '24 × 30 in', aspect: '4 / 5', prodigiSize: '24X30', price: 161 },
195 '24x36': { label: '24 × 36 in', aspect: '2 / 3', prodigiSize: '24X36', price: 173 },
196 '30x40': { label: '30 × 40 in', aspect: '3 / 4', prodigiSize: '30X40', price: 222 },
197 },
198 defaultSize: '12x18',
199 },
200 stretched: {
201 label: 'Stretched Canvas',
202 sub: 'A frameless gallery-wrapped canvas on a 38mm pine stretcher.',
203 specs: [
204 '400gsm artist-grade cotton canvas',
205 '38mm kiln-dried knotless pine stretcher',
206 'Hand-stretched & gallery-wrapped',
207 'Choice of edge wrap finish',
208 'Latex / UVgel print, 200-year permanence',
209 ],
210 hero: '/products/stretched-hero-pet.png',
211 photos: [
212 { src: '/products/stretched-hero-pet.png', label: 'Frameless stretched canvas' },
213 { src: '/products/stretched-corner-pet-v2.png', label: '38mm corner fold' },
214 { src: '/products/stretched-imagewrap-pet-v3.png', label: 'Image-wrapped edge' },
215 { src: '/products/stretched-texture.jpg', label: 'Canvas texture' },
216 ],
217 // Frameless — no frame finish or mat. Edge finish is the `wrap`
218 // attribute instead (see availableWraps + prodigi-skus.ts).
219 availableFrames: [] as const,
220 availableWraps: ['imagewrap', 'mirror', 'white', 'black'] as const,
221 // No frame moulding, no mat: the preview renders the bare canvas.
222 frameW: 0,
223 matteW: 0,
224 prodigiSkuPrefix: 'GLOBAL-CAN',
225 // GLOBAL-CAN is INCH-coded; sizeIds carry the inch code verbatim. All
226 // wraps cost the same, so there's a single at-cost price per size.
227 sizes: {
228 '8x10': { label: '8 × 10 in', aspect: '4 / 5', prodigiSize: '8X10', price: 49 },
229 '8x12': { label: '8 × 12 in', aspect: '2 / 3', prodigiSize: '8X12', price: 49 },
230 '10x10': { label: '10 × 10 in', aspect: '1 / 1', prodigiSize: '10X10', price: 49 },
231 '11x14': { label: '11 × 14 in', aspect: '11 / 14', prodigiSize: '11X14', price: 58 },
232 '12x12': { label: '12 × 12 in', aspect: '1 / 1', prodigiSize: '12X12', price: 58 },
233 '12x16': { label: '12 × 16 in', aspect: '3 / 4', prodigiSize: '12X16', price: 58 },
234 '12x18': { label: '12 × 18 in', aspect: '2 / 3', prodigiSize: '12X18', price: 58 },
235 '16x16': { label: '16 × 16 in', aspect: '1 / 1', prodigiSize: '16X16', price: 66 },
236 '16x20': { label: '16 × 20 in', aspect: '4 / 5', prodigiSize: '16X20', price: 66 },
237 '18x24': { label: '18 × 24 in', aspect: '3 / 4', prodigiSize: '18X24', price: 74 },
238 '20x20': { label: '20 × 20 in', aspect: '1 / 1', prodigiSize: '20X20', price: 74 },
239 '20x24': { label: '20 × 24 in', aspect: '5 / 6', prodigiSize: '20X24', price: 82 },
240 '20x28': { label: '20 × 28 in', aspect: '5 / 7', prodigiSize: '20X28', price: 91 },
241 '20x30': { label: '20 × 30 in', aspect: '2 / 3', prodigiSize: '20X30', price: 91 },
242 '24x24': { label: '24 × 24 in', aspect: '1 / 1', prodigiSize: '24X24', price: 82 },
243 '24x30': { label: '24 × 30 in', aspect: '4 / 5', prodigiSize: '24X30', price: 91 },
244 '24x36': { label: '24 × 36 in', aspect: '2 / 3', prodigiSize: '24X36', price: 99 },
245 '30x40': { label: '30 × 40 in', aspect: '3 / 4', prodigiSize: '30X40', price: 132 },
246 },
247 defaultSize: '16x20',
248 },
249} as const;
250
251export type ProductId = keyof typeof PRODUCTS;
252export type SizeId = string;
253
254// Orientation the customer hangs the print in. Every size in the catalog
255// above is authored portrait-or-square; landscape is expressed by
256// transposing that size's aspect (and display label) at read time —
257// Prodigi has no separate landscape SKU and auto-orients the framed
258// product to match the asset we send, so the *same* prodigiSize + price
259// covers both orientations. Square sizes have no landscape variant.
260export type Orientation = 'portrait' | 'landscape';
261
262/** Parse a 'W / H' aspect string into [w, h], or null if unparseable. */
263function parseAspect(aspectStr: string): [number, number] | null {
264 const m = aspectStr.match(/^\s*(\d+(?:\.\d+)?)\s*\/\s*(\d+(?:\.\d+)?)\s*$/);
265 if (!m) return null;
266 const w = parseFloat(m[1]);
267 const h = parseFloat(m[2]);
268 if (!(w > 0) || !(h > 0)) return null;
269 return [w, h];
270}
271
272/** True for a 1:1 (square) aspect string — squares have no orientation. */
273export function isSquareAspect(aspectStr: string): boolean {
274 const wh = parseAspect(aspectStr);
275 return !!wh && Math.abs(wh[0] - wh[1]) < 0.001;
276}
277
278/** Swap 'W / H' → 'H / W'. No-op for square or unparseable input. */
279export function transposeAspect(aspectStr: string): string {
280 const wh = parseAspect(aspectStr);
281 if (!wh || Math.abs(wh[0] - wh[1]) < 0.001) return aspectStr;
282 return `${wh[1]} / ${wh[0]}`;
283}
284
285/** Frame aspect string ('W / H', e.g. '3 / 4') for a product+size,
286 * oriented portrait (catalog default) or landscape (transposed), or
287 * null if either is missing/unknown. Used to generate + crop the
288 * artwork in the customer's chosen frame shape. */
289export function frameAspect(
290 productId: ProductId | undefined,
291 sizeId: string | undefined,
292 orientation: Orientation = 'portrait',
293): string | null {
294 if (!productId || !sizeId) return null;
295 const sizes = PRODUCTS[productId]?.sizes as Record<string, { aspect: string }> | undefined;
296 const aspect = sizes?.[sizeId]?.aspect ?? null;
297 if (!aspect) return null;
298 return orientation === 'landscape' ? transposeAspect(aspect) : aspect;
299}
300
301/** Display label for a product+size in the chosen orientation, e.g.
302 * '8 × 10 in' portrait → '10 × 8 in' landscape. Square sizes and
303 * unknown sizes are returned unchanged. Falls back to the size id when
304 * the size is missing. */
305export function sizeLabel(
306 productId: ProductId | undefined,
307 sizeId: string | undefined,
308 orientation: Orientation = 'portrait',
309): string {
310 if (!productId || !sizeId) return sizeId ?? '';
311 const sizes = PRODUCTS[productId]?.sizes as Record<string, { label: string; aspect: string }> | undefined;
312 const row = sizes?.[sizeId];
313 if (!row) return sizeId;
314 if (orientation !== 'landscape' || isSquareAspect(row.aspect)) return row.label;
315 // Swap the two dimensions in '8 × 10 in' → '10 × 8 in'.
316 return row.label.replace(/^(\d+)(\s*×\s*)(\d+)/, '$3$2$1');
317}
318
319/** Size ids available for an orientation. Portrait exposes every size
320 * (including squares); landscape drops the squares, since a square has
321 * no distinct landscape form. */
322export function sizesForOrientation(productId: ProductId, orientation: Orientation): string[] {
323 const sizes = PRODUCTS[productId].sizes as Record<string, { aspect: string }>;
324 const ids = Object.keys(sizes);
325 if (orientation !== 'landscape') return ids;
326 return ids.filter((id) => !isSquareAspect(sizes[id].aspect));
327}
328
329function sizeRow(productId: ProductId, sizeId: string) {
330 const sizes = PRODUCTS[productId].sizes as Record<
331 string,
332 { label: string; aspect: string; prodigiSize: string; price: number; nomatPrice?: number }
333 >;
334 const row = sizes[sizeId];
335 if (!row) throw new Error(`Unknown size ${sizeId} for product ${productId}`);
336 return row;
337}
338
339/** "No matte" carries its own price on products that offer a no-mat
340 * variant (box frame → FRA-BOX-NM, classic → GLOBAL-CFP). */
341function usesNoMatPrice(row: { nomatPrice?: number }, matteId: string | null | undefined): boolean {
342 return matteId === 'nomat' && typeof row.nomatPrice === 'number';
343}
344
345/** At-cost price in dollars: what the customer pays and Stripe charges.
346 * The portrait artwork is free, so custom style references and extra
347 * pets add nothing. */
348export function salePrice(
349 productId: ProductId,
350 sizeId: string,
351 matteId?: string | null,
352): number {
353 const row = sizeRow(productId, sizeId);
354 return usesNoMatPrice(row, matteId) ? row.nomatPrice! : row.price;
355}
356
357/** At-cost price in cents — what Stripe Checkout actually charges. */
358export function priceCents(
359 productId: ProductId,
360 sizeId: string,
361 matteId?: string | null,
362): number {
363 return salePrice(productId, sizeId, matteId) * 100;
364}
365
366/** Lowest price across all sizes for a product. */
367export function startingSalePrice(productId: ProductId): number {
368 const sizes = PRODUCTS[productId].sizes as Record<string, { price: number }>;
369 return Math.min(...Object.values(sizes).map((s) => s.price));
370}
371
372/** Lowest price across the ENTIRE catalogue, used for the gallery's
373 * "From $X" label. */
374export function catalogStartingSalePrice(): number {
375 return Math.min(...(Object.keys(PRODUCTS) as ProductId[]).map(startingSalePrice));
376}