[object Object]

← back to Carmelwallpapers

fix: wire vendor sort handler, add SKU option, drop dead Price options

5958e2e4920824ac8e458a129917088962911b86 · 2026-05-19 08:01:20 -0700 · Steve Abrams

Product data has no price field so Price sort was a no-op; SKU sort
falls back to handle. Vendor option existed in the select but had no
server-side sort handler.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 5958e2e4920824ac8e458a129917088962911b86
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Tue May 19 08:01:20 2026 -0700

    fix: wire vendor sort handler, add SKU option, drop dead Price options
    
    Product data has no price field so Price sort was a no-op; SKU sort
    falls back to handle. Vendor option existed in the select but had no
    server-side sort handler.
    
    Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---
 server.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/server.js b/server.js
index ead9d2c..b04006d 100644
--- a/server.js
+++ b/server.js
@@ -82,6 +82,7 @@ function hue(p){const rgb=hexToRgb(dominantHex(p));if(!rgb)return 999;const [h,s
 function sortProducts(list, mode) {
   if (mode === 'sku') return [...list].sort((a,b) => String(a.sku || a.handle || '').localeCompare(String(b.sku || b.handle || '')));
   if (mode === 'title') return [...list].sort((a,b) => String(a.title || '').localeCompare(String(b.title || '')));
+  if (mode === 'vendor') return [...list].sort((a,b) => String(a.vendor || '').localeCompare(String(b.vendor || '')) || String(a.title || '').localeCompare(String(b.title || '')));
   if (mode === 'color') return [...list].sort((a,b) => colorRank(a) - colorRank(b) || String(a.title || '').localeCompare(String(b.title || '')));
   if (mode === 'style') return [...list].sort((a,b) => styleKey(a).localeCompare(styleKey(b)) || String(a.title || '').localeCompare(String(b.title || '')));
   if (mode === 'light-dark') return [...list].sort((a,b) => luminance(b) - luminance(a)); // bright first
@@ -333,10 +334,9 @@ ${HEADER_HTML(q, sort, density)}
         <option value="newest" ${sort==='newest'?'selected':''}>Newest</option>
         <option value="color" ${sort==='color'?'selected':''}>Color</option>
         <option value="style" ${sort==='style'?'selected':''}>Style</option>
+        <option value="sku" ${sort==='sku'?'selected':''}>SKU A→Z</option>
         <option value="title" ${sort==='title'?'selected':''}>Title A→Z</option>
         <option value="vendor" ${sort==='vendor'?'selected':''}>Vendor A→Z</option>
-        <option value="price-asc" ${sort==='price-asc'?'selected':''}>Price ↑</option>
-        <option value="price-desc" ${sort==='price-desc'?'selected':''}>Price ↓</option>
       </select>
       <label class="density-label" aria-label="Grid density">
         <svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" aria-hidden="true"><rect x="0" y="0" width="4" height="4"/><rect x="6" y="0" width="4" height="4"/><rect x="12" y="0" width="4" height="4"/><rect x="0" y="6" width="4" height="4"/><rect x="6" y="6" width="4" height="4"/><rect x="12" y="6" width="4" height="4"/></svg>

← 20aecc2 fix: add noreferrer to external target=_blank links  ·  back to Carmelwallpapers  ·  stage2: wire carmelwallpapers onto shared catalog (hand-tail ccc83e1 →