[object Object]

← back to Reno Visualizer

Step 2: server.js — load products from shopify-catalog.json

f3bc6c53d1b56b6d05ec5c741d42de34518945da · 2026-07-16 07:36:25 -0700 · Steve Abrams

loadProducts() now reads shopify-catalog.json first (real images,
titles, vendors, prices, handles). Builds shopify_url from
checkout_domain + handle for every product. Falls back to legacy
products.json if catalog missing. Lead body now persists
pattern_handle, pattern_shopify_url, name, interest fields.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files touched

Diff

commit f3bc6c53d1b56b6d05ec5c741d42de34518945da
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Thu Jul 16 07:36:25 2026 -0700

    Step 2: server.js — load products from shopify-catalog.json
    
    loadProducts() now reads shopify-catalog.json first (real images,
    titles, vendors, prices, handles). Builds shopify_url from
    checkout_domain + handle for every product. Falls back to legacy
    products.json if catalog missing. Lead body now persists
    pattern_handle, pattern_shopify_url, name, interest fields.
    
    Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---
 server.js | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/server.js b/server.js
index b166217..8f31bf4 100644
--- a/server.js
+++ b/server.js
@@ -41,9 +41,27 @@ function bodyJson(req) {
 }
 
 // --- products ---
+// Load from shopify-catalog.json (real Shopify data); fall back to legacy products.json
 function loadProducts() {
-  try { return JSON.parse(fs.readFileSync(path.join(DIR, 'data', 'products.json'), 'utf8')); }
-  catch { return []; }
+  try {
+    const catalog = JSON.parse(fs.readFileSync(path.join(DIR, 'data', 'shopify-catalog.json'), 'utf8'));
+    const checkoutDomain = catalog.checkout_domain || 'www.designerwallcoverings.com';
+    return (catalog.products || []).map(p => ({
+      sku: p.sku,
+      title: p.title,
+      vendor: p.vendor,
+      type: p.type,
+      image: p.image,
+      image_url: p.image,
+      price: p.price,
+      handle: p.handle,
+      variant_id: p.variant_id,
+      shopify_url: `https://${checkoutDomain}/products/${p.handle}`,
+    }));
+  } catch {
+    try { return JSON.parse(fs.readFileSync(path.join(DIR, 'data', 'products.json'), 'utf8')); }
+    catch { return []; }
+  }
 }
 function luminance(hex) {
   if (!/^#?[0-9a-f]{6}$/i.test(hex || '')) return 999;
@@ -159,9 +177,13 @@ http.createServer((req, res) => {
       const lead = {
         id: Date.now().toString(36) + Math.random().toString(36).slice(2,6),
         email: body.email,
+        name: body.name || null,
+        interest: body.interest || null,
         pattern_sku: body.pattern_sku || null,
         pattern_title: body.pattern_title || null,
         pattern_vendor: body.pattern_vendor || null,
+        pattern_handle: body.pattern_handle || null,
+        pattern_shopify_url: body.pattern_shopify_url || null,
         room_label: body.room_label || null,
         message: body.message || null,
         created_at: new Date().toISOString(),

← 631dcaf Step 1: add real Shopify catalog (200 products, read-only st  ·  back to Reno Visualizer  ·  Step 3: index.html — real Shopify images + product deep-link 3035e40 →