[object Object]

← back to Designer Wallcoverings

Daisy Bennett + Sag Harbor: enforce 8-yard order increments (min=8/step=8, unit=Per Yard, display_variant tag)

47004a53ba7d3affd34ab356251004a215c70a87 · 2026-07-06 13:55:07 -0700 · Steve

Files touched

Diff

commit 47004a53ba7d3affd34ab356251004a215c70a87
Author: Steve <steve@designerwallcoverings.com>
Date:   Mon Jul 6 13:55:07 2026 -0700

    Daisy Bennett + Sag Harbor: enforce 8-yard order increments (min=8/step=8, unit=Per Yard, display_variant tag)
---
 .../set-increment-daisy-bennett.cjs                | 43 ++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/scripts/wallquest-refresh/set-increment-daisy-bennett.cjs b/scripts/wallquest-refresh/set-increment-daisy-bennett.cjs
new file mode 100644
index 00000000..7ff3b7e6
--- /dev/null
+++ b/scripts/wallquest-refresh/set-increment-daisy-bennett.cjs
@@ -0,0 +1,43 @@
+// Enforce 8-YARD INCREMENTS on the natural-wallcovering products (Steve 2026-07-06 "8 yard
+// increments only"). Sets the DW canonical order-min/increment metafields + unit_of_measure +
+// adds the display_variant tag so the storefront theme enforces the 8-yard step on the qty control.
+const https = require('https');
+const { execSync } = require('child_process');
+const TOK = process.env.SHOPIFY_ADMIN_TOKEN;
+const DOMAIN = 'designer-laboratory-sandbox.myshopify.com';
+const INC = process.env.INC || '8';
+const EXTRA_IDS = (process.env.EXTRA_IDS || '').split(',').filter(Boolean); // extra product ids (e.g. Sag Harbor)
+const LIMIT = parseInt(process.env.LIMIT || '999', 10);
+
+const MF = [
+  { namespace: 'global', key: 'v_prods_quantity_order_min', value: INC, type: 'single_line_text_field' },
+  { namespace: 'global', key: 'v_prods_quantity_order_units', value: INC, type: 'single_line_text_field' },
+  { namespace: 'dwc', key: 'order_unit', value: INC, type: 'single_line_text_field' },
+  { namespace: 'global', key: 'unit_of_measure', value: 'Priced Per Yard', type: 'single_line_text_field' },
+];
+function shopify(method, path, body) {
+  return new Promise((res, rej) => { const data = body ? JSON.stringify(body) : null;
+    const req = https.request({ hostname: DOMAIN, path: `/admin/api/2024-10/${path}`, method,
+      headers: { 'X-Shopify-Access-Token': TOK, 'Content-Type': 'application/json', ...(data?{'Content-Length':Buffer.byteLength(data)}:{}) } },
+      r => { let d=''; r.on('data',c=>d+=c); r.on('end',()=>{ try{const j=d?JSON.parse(d):{}; r.statusCode<300?res(j):rej(new Error(r.statusCode+' '+d.slice(0,120)));}catch(e){rej(e);} }); });
+    req.on('error', rej); if (data) req.write(data); req.end(); });
+}
+async function apply(pid) {
+  for (const m of MF) { try { await shopify('POST', `products/${pid}/metafields.json`, { metafield: m }); } catch(e){} await new Promise(r=>setTimeout(r,90)); }
+  // ensure display_variant tag present (theme reads it to render the qty/increment control)
+  const cur = await shopify('GET', `products/${pid}.json?fields=tags`);
+  const tags = (cur.product.tags||'').split(',').map(s=>s.trim()).filter(Boolean);
+  if (!tags.includes('display_variant')) { tags.push('display_variant'); await shopify('PUT', `products/${pid}.json`, { product:{ id:Number(pid), tags: tags.join(', ') } }); }
+}
+(async () => {
+  const daisy = execSync(`PGPASSWORD=DW2024SecurePass psql -h 127.0.0.1 -U dw_admin -d dw_unified -tAc "SELECT shopify_product_id FROM daisy_bennett_catalog WHERE on_shopify AND shopify_product_id IS NOT NULL ORDER BY dw_sku"`).toString().trim().split('\n').filter(Boolean);
+  const ids = [...daisy, ...EXTRA_IDS].slice(0, LIMIT);
+  console.log(`Setting ${INC}-yard increments on ${ids.length} products (${daisy.length} Daisy + ${EXTRA_IDS.length} extra)\n`);
+  let ok=0, fail=0;
+  for (const pid of ids) {
+    try { await apply(pid); ok++; if (ok<=3 || ok%20===0) console.log(`  ✅ ${pid} → min ${INC} / step ${INC} yd + display_variant`); }
+    catch(e){ console.error(`  ❌ ${pid}: ${e.message}`); fail++; }
+    await new Promise(r=>setTimeout(r,150));
+  }
+  console.log(`\nINCREMENT SET — ok=${ok} fail=${fail}`);
+})().catch(e=>{console.error('FATAL',e.message);process.exit(1);});

← ece3218f Daisy Bennett: reconcile SKUs to GRS- (no DW); retitle all 6  ·  back to Designer Wallcoverings  ·  Add DWTT double-roll min/step + dims metafield writer (dry-r 6cad6ab6 →