From 5ddb142c8f178424a541daabfedd0bfa7b91ad4c Mon Sep 17 00:00:00 2001 From: Reef Date: Sat, 22 Aug 2026 12:41:39 +0000 Subject: [PATCH] Update upsell.html buy buttons: form POST to /shop/post_basket with info=uuid --- odoo/upsell.html | 58 ++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/odoo/upsell.html b/odoo/upsell.html index 3a30b01..e65ad3e 100644 --- a/odoo/upsell.html +++ b/odoo/upsell.html @@ -298,8 +298,6 @@ // ── Webhooks ───────────────────────────────────────────────────────────── const getContract_Webhook = "https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/0c8536be-d175-4740-8e78-123159193b23"; - const buy_webhook = - "https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/2366cc41-bfd9-41c0-b9b4-bea1e60726f1"; // ── Plan hierarchy (index = tier, lower = cheaper) ──────────────────────── const PLAN_ORDER = [ @@ -337,37 +335,43 @@ const uuid = params.get("uuid") || ""; document.getElementById("uuidText").textContent = uuid || "–"; + // ── Product ID mapping ───────────────────────────────────────── + const PRODUCT_IDS = { + sidehustle: 54, + ontherise: 55, + powerhouse: 56, + }; + // ── Buy handler ─────────────────────────────────────────────────────────── - async function buyProduct(productId) { + function buyProduct(productId) { if (!uuid) { alert("Missing uuid parameter in URL."); return; } - try { - const res = await fetch(buy_webhook, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ uuid, product_id: productId }), - }); - if (!res.ok) throw new Error("HTTP " + res.status); - - document.body.innerHTML = ` -
-
-

Request sent!

-

- Please check your email for the payment link and confirmation.
- New features will be active as soon as the payment is complete. -

-
`; - } catch (err) { - console.error(err); - alert( - "Something went wrong. Please try again or contact support.", - ); + var pid = PRODUCT_IDS[productId]; + if (!pid) { + alert("Unknown product."); + return; } + var form = document.createElement("form"); + form.method = "POST"; + form.action = window.location.origin + "/shop/post_basket"; + form.target = "_blank"; + form.style.display = "none"; + var basket = document.createElement("input"); + basket.type = "hidden"; + basket.name = "basket"; + var item = { product_id: pid, qty: 1, info: uuid }; + basket.value = JSON.stringify([item]); + form.appendChild(basket); + var clear = document.createElement("input"); + clear.type = "hidden"; + clear.name = "clear"; + clear.value = "1"; + form.appendChild(clear); + document.body.appendChild(form); + form.submit(); + document.body.removeChild(form); } // ── Wire buy buttons ──────────────────────────────────────────────────────