← back to Dw Contact Us Pages
cohorts/maharam-stock-2026-guard-contact-us-skip.patch
51 lines
--- a/scripts/cadence/stock-2026-guard.js 2026-09-26 08:54:29
+++ b/scripts/cadence/stock-2026-guard.js 2026-09-26 08:54:29
@@ -54,20 +54,27 @@
const SCAN = `query($cursor:String){ products(first:100, after:$cursor, query:"status:active inventory_total:<1"){
pageInfo{ hasNextPage endCursor }
- nodes{ id title vendor variants(first:50){ nodes{ sku price inventoryQuantity inventoryItem{ id tracked } } } }
+ nodes{ id title vendor templateSuffix variants(first:50){ nodes{ sku price inventoryQuantity inventoryItem{ id tracked } } } }
} }`;
const INV_SET = `mutation($input:InventorySetQuantitiesInput!){ inventorySetQuantities(input:$input){ userErrors{ field message code } } }`;
(async () => {
const started = new Date().toISOString();
const targets = []; // { title, vendor, items:[inventoryItemId], skus:[] }
- let cursor = null, pages = 0, scanned = 0;
+ let cursor = null, pages = 0, scanned = 0, skippedContactUs = 0;
do {
const j = await gql(SCAN, { cursor });
const conn = j.data && j.data.products;
if (!conn) { console.error('[stock-2026-guard] scan error:', JSON.stringify(j.errors || j)); break; }
for (const p of conn.nodes) {
scanned++;
+ // GUARD TK-11669: never re-stock a CONTACT-US (quote-only) product. The contact-us mechanism
+ // (~/Projects/dw-contact-us-pages, TK-11925) DELIBERATELY hardens the sellable variant to
+ // tracked + on_hand 0 + DENY so it cannot be bought; re-stamping 2026 here silently re-opens
+ // checkout on a quote-only line. MEASURED 2026-09-26: the 5 TK-11925 products whose Sample is
+ // untracked (so product inventory_total < 1 puts them in this scan) were found back at qty>0,
+ // availableForSale=true. Keyed on the mechanism (templateSuffix), never on a vendor name.
+ if (p.templateSuffix === 'contact-us') { skippedContactUs++; continue; }
// GUARD TK-11299: never re-stock a $0 quote-only variant. Setting on_hand=2026 on a $0 variant
// flips availableForSale=true → orderable at $0 (real revenue defect; TK-10825/10965/11140/11301/11357).
// The "active products are never out of stock" rule is for PRICED sellable variants — a $0
@@ -85,7 +92,7 @@
} while (cursor && pages < 200);
const pairs = targets.flatMap(t => t.items.map(id => ({ inventoryItemId: id, locationId: INV_LOCATION, quantity: QTY })));
- console.log(`[stock-2026-guard] scanned ${scanned} active-≤0 candidates · ${targets.length} products with a TRACKED variant ≤0 · ${pairs.length} variant-sets needed`);
+ console.log(`[stock-2026-guard] scanned ${scanned} active-≤0 candidates (${skippedContactUs} contact-us skipped) · ${targets.length} products with a TRACKED variant ≤0 · ${pairs.length} variant-sets needed`);
targets.slice(0, 15).forEach(t => console.log(' ·', String(t.title).slice(0, 50), '|', t.skus.join(', ')));
let applied = 0; const errors = [];
@@ -102,7 +109,7 @@
console.log('[stock-2026-guard] nothing to fix — every active tracked product is in stock. ✅');
}
- const report = { ts: started, store: STORE, committed: COMMIT, scanned, productsFixed: targets.length, variantSets: pairs.length, applied, errors: errors.slice(0, 20) };
+ const report = { ts: started, store: STORE, committed: COMMIT, scanned, skippedContactUs, productsFixed: targets.length, variantSets: pairs.length, applied, errors: errors.slice(0, 20) };
try { fs.writeFileSync(OUT, JSON.stringify(report, null, 2)); } catch (e) {}
// best-effort CNCP card when it actually fixed something (matches the DW canary fleet pattern)