Pass promo code through compliance checker to order page

- Compliance checker reads ?code= from URL, stores it, passes it
  through to the order page CTA link
- Allows email campaigns to link to checker with coupon pre-applied

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
justin 2026-05-21 15:16:27 -05:00
parent ba2f6eb667
commit 868b0eeca5

View file

@ -225,6 +225,9 @@ import Base from "../../layouts/Base.astro";
// Race condition guard — cancel prior fetch when new one starts
let currentController = null;
// Promo code passthrough from URL (e.g. ?code=MEMORIAL25)
let urlPromoCode = "";
// --- Name search ---
nameSearchBtn?.addEventListener("click", runNameSearch);
nameInput?.addEventListener("keydown", (e) => { if (e.key === "Enter") runNameSearch(); });
@ -1026,7 +1029,7 @@ import Base from "../../layouts/Base.astro";
// Update link
const btn = document.getElementById("get-started-btn");
if (btn) {
btn.href = `/order/fcc-compliance?services=${selectedIds.join(",")}&frn=${frn}`;
btn.href = `/order/fcc-compliance?services=${selectedIds.join(",")}&frn=${frn}${urlPromoCode ? "&code=" + encodeURIComponent(urlPromoCode) : ""}`;
}
}
@ -1130,6 +1133,7 @@ import Base from "../../layouts/Base.astro";
const params = new URLSearchParams(window.location.search);
const frn = params.get("frn");
const entity = params.get("entity");
urlPromoCode = params.get("code") || params.get("promo") || "";
if (frn) {
frnInput.value = frn;