[object Object]

← back to Designer Wallcoverings

validate-before-activate: fix sample-variant false-positive — accept any -sample SKU (or a 'Sample'-titled variant), not an exact {dwSku}-Sample match. The strict match falsely flagged every product whose sample is keyed to mfr_sku (e.g. SWAN-104-sample), inflating residue + wrongly blocking legit products at the activation chokepoint

e69ef2ba16577b76f2cc9273a1058378eb3f4e08 · 2026-06-21 08:24:27 -0700 · Steve

Files touched

Diff

commit e69ef2ba16577b76f2cc9273a1058378eb3f4e08
Author: Steve <steve@designerwallcoverings.com>
Date:   Sun Jun 21 08:24:27 2026 -0700

    validate-before-activate: fix sample-variant false-positive — accept any -sample SKU (or a 'Sample'-titled variant), not an exact {dwSku}-Sample match. The strict match falsely flagged every product whose sample is keyed to mfr_sku (e.g. SWAN-104-sample), inflating residue + wrongly blocking legit products at the activation chokepoint
---
 shopify/scripts/lib/validate-before-activate.js | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/shopify/scripts/lib/validate-before-activate.js b/shopify/scripts/lib/validate-before-activate.js
index 5e237337..90b49e6d 100644
--- a/shopify/scripts/lib/validate-before-activate.js
+++ b/shopify/scripts/lib/validate-before-activate.js
@@ -161,11 +161,14 @@ function validateBeforeActivate(product) {
   // ---------- SAMPLE VARIANT ----------
   const variants = Array.isArray(p.variants) ? p.variants : [];
   const skuList = variants.map(v => (typeof v === 'string' ? v : (v && (v.sku || (v.inventoryItem && v.inventoryItem.sku))) || '')).map(s => String(s).toLowerCase());
-  const dwSku = String(p.dwSku || '').toLowerCase();
-  const wantSample = dwSku ? `${dwSku}-sample` : null;
-  const hasSample = wantSample
-    ? skuList.includes(wantSample)
-    : skuList.some(s => s.endsWith('-sample'));
+  // A product "has a sample" if ANY variant SKU ends in -sample, OR (when the
+  // variant objects carry a title) a variant is titled "Sample". The standing
+  // rule wants a sample variant present — it does NOT require the sample SKU base
+  // to equal the DW SKU. The old exact `${dwSku}-Sample` match falsely flagged
+  // every product whose sample is keyed to the mfr_sku (e.g. SWAN-104-sample),
+  // inflating residue and wrongly blocking legit products at the chokepoint.
+  const titledSample = variants.some(v => v && typeof v === 'object' && /^\s*sample\s*$/i.test(v.title || ''));
+  const hasSample = titledSample || skuList.some(s => s.endsWith('-sample'));
   if (!hasSample) { reasons.push('missing sample variant'); }
 
   return { ok: reasons.length === 0, reasons, tags: [...new Set(tags)] };

← 1c17d27c active-gate-add-samples: additive sample-variant pass for th  ·  back to Designer Wallcoverings  ·  cadence: disarm --collections auto-join to Trending (Steve 2 2e01b21e →