const urlParams = new URLSearchParams(window.location.search);
const productId = urlParams.get(“product”);
// Ensure only expected product IDs
const productMap = {
3030: “3030”,
3031: “3031”,
3032: “3032”
};
const formFieldParam = “entry.1653888637”; // Your Google Form field ID
const formBase = “https://docs.google.com/forms/d/e/1FAIpQLScqHUovaQRRKCHnQGnwWBDD1u_uNi6nrM6IL1Z12Wvs1GvGrw/viewform”;
// Construct full form URL with product ID
const fullFormURL = `${formBase}?usp=pp_url&${formFieldParam}=${productId}`;
document.getElementById(“google-form-frame”).src = fullFormURL;
const iframe = document.getElementById(“google-form-frame”);
const observer = new MutationObserver(() => {
try {
const doc = iframe.contentDocument || iframe.contentWindow.document;
const bodyText = doc.body.innerText;
if (bodyText.includes(“Thank you”) || bodyText.includes(“response has been recorded”)) {
setTimeout(() => {
window.location.href = `/checkout/?add-to-cart=${productMap[productId]}`;
}, 3000); // Redirect after 3 seconds
}
} catch (e) {
// Ignore errors from cross-origin blocking
}
});
observer.observe(iframe, {
childList: true,
subtree: true
});
Recent Comments