From 472e9f92dc033664d88610749eea8bf1e67833e3 Mon Sep 17 00:00:00 2001 From: justin Date: Fri, 29 May 2026 15:07:45 -0500 Subject: [PATCH] Fix discount fetch: trigger on any pre-filled value + debounced input fetchDiscount now fires on page load if promo field has ANY value (not just from URL param), plus debounced on input events. Co-Authored-By: Claude Opus 4.6 (1M context) --- site/public/order/dot-compliance/index.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/site/public/order/dot-compliance/index.html b/site/public/order/dot-compliance/index.html index 22b2f13..12682e3 100644 --- a/site/public/order/dot-compliance/index.html +++ b/site/public/order/dot-compliance/index.html @@ -455,10 +455,12 @@ function fetchDiscount() { updateTotal(); }).catch(function() { activeDiscount = null; updateTotal(); }); } -// Fetch on load if promo pre-filled -if (promoFromUrl) { setTimeout(fetchDiscount, 500); } -// Fetch on blur of promo field -document.getElementById("pw-promo").addEventListener("blur", fetchDiscount); +// Fetch on load if promo field has any value +var promoField = document.getElementById("pw-promo"); +if (promoField.value.trim()) { setTimeout(fetchDiscount, 300); } +// Fetch on blur and input of promo field +promoField.addEventListener("blur", fetchDiscount); +promoField.addEventListener("input", function() { clearTimeout(promoField._debounce); promoField._debounce = setTimeout(fetchDiscount, 600); }); function updateTotal() { var selected = [];