[object Object]

← back to Hollywood Wallcoverings

customcreator: reject blank/zero/NaN mural dimensions before clamp (was silently becoming a 50x50cm order)

8226967fe1081e4b6818abef42738ef9de751cd9 · 2026-06-21 18:54:44 -0700 · Steve Abrams

Files touched

Diff

commit 8226967fe1081e4b6818abef42738ef9de751cd9
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Sun Jun 21 18:54:44 2026 -0700

    customcreator: reject blank/zero/NaN mural dimensions before clamp (was silently becoming a 50x50cm order)
---
 customcreator.js | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/customcreator.js b/customcreator.js
index d74eb1f..0dc8fe9 100644
--- a/customcreator.js
+++ b/customcreator.js
@@ -109,10 +109,12 @@ async function makeDraft(body) {
     line = { title: `${pattern} — Sample`, originalUnitPrice: SAMPLE.toFixed(2), quantity: 1, requiresShipping: true, taxable: true, customAttributes: [{ key: 'Design', value: sku }, { key: 'Type', value: 'Sample' }] };
   } else {
     const f = body.unit === 'cm' ? 1 : CM_PER_IN;
-    const w_cm = clamp((parseFloat(body.width) || 0) * f, MIN_CM, MAX_CM);
-    const h_cm = clamp((parseFloat(body.height) || 0) * f, MIN_CM, MAX_CM);
+    const rawW = parseFloat(body.width), rawH = parseFloat(body.height);
+    if (!(rawW > 0) || !(rawH > 0)) return { error: 'Please enter a valid width and height.' };
+    const w_cm = clamp(rawW * f, MIN_CM, MAX_CM);
+    const h_cm = clamp(rawH * f, MIN_CM, MAX_CM);
     const area = (w_cm / 100) * (h_cm / 100);
-    if (!(area > 0)) return { error: 'invalid dimensions' };
+    if (!(area > 0)) return { error: 'invalid dimensions' }; // defensive; unreachable post-clamp
     const price = +(RATE_SQM * area).toFixed(2);
     const wDim = ftIn(w_cm / CM_PER_IN), hDim = ftIn(h_cm / CM_PER_IN);
     line = { title: `${pattern} — Custom Mural ${wDim} × ${hDim}`, originalUnitPrice: price.toFixed(2), quantity: 1, requiresShipping: true, taxable: true,

← 8f6f5b9 CustomCreator configurator: graceful gallery fallback for un  ·  back to Hollywood Wallcoverings  ·  add Hollywood Wallcoverings Constant Contact campaign draft a36d0d1 →