Public Access
Update upsell.html buy buttons: form POST to /shop/post_basket with info=uuid
This commit is contained in:
+31
-27
@@ -298,8 +298,6 @@
|
|||||||
// ── Webhooks ─────────────────────────────────────────────────────────────
|
// ── Webhooks ─────────────────────────────────────────────────────────────
|
||||||
const getContract_Webhook =
|
const getContract_Webhook =
|
||||||
"https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/0c8536be-d175-4740-8e78-123159193b23";
|
"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) ────────────────────────
|
// ── Plan hierarchy (index = tier, lower = cheaper) ────────────────────────
|
||||||
const PLAN_ORDER = [
|
const PLAN_ORDER = [
|
||||||
@@ -337,37 +335,43 @@
|
|||||||
const uuid = params.get("uuid") || "";
|
const uuid = params.get("uuid") || "";
|
||||||
document.getElementById("uuidText").textContent = uuid || "–";
|
document.getElementById("uuidText").textContent = uuid || "–";
|
||||||
|
|
||||||
|
// ── Product ID mapping ─────────────────────────────────────────
|
||||||
|
const PRODUCT_IDS = {
|
||||||
|
sidehustle: 54,
|
||||||
|
ontherise: 55,
|
||||||
|
powerhouse: 56,
|
||||||
|
};
|
||||||
|
|
||||||
// ── Buy handler ───────────────────────────────────────────────────────────
|
// ── Buy handler ───────────────────────────────────────────────────────────
|
||||||
async function buyProduct(productId) {
|
function buyProduct(productId) {
|
||||||
if (!uuid) {
|
if (!uuid) {
|
||||||
alert("Missing uuid parameter in URL.");
|
alert("Missing uuid parameter in URL.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
var pid = PRODUCT_IDS[productId];
|
||||||
const res = await fetch(buy_webhook, {
|
if (!pid) {
|
||||||
method: "POST",
|
alert("Unknown product.");
|
||||||
headers: { "Content-Type": "application/json" },
|
return;
|
||||||
body: JSON.stringify({ uuid, product_id: productId }),
|
|
||||||
});
|
|
||||||
if (!res.ok) throw new Error("HTTP " + res.status);
|
|
||||||
|
|
||||||
document.body.innerHTML = `
|
|
||||||
<div style="text-align:center;padding:80px 20px;background:#fff;border-radius:14px;
|
|
||||||
max-width:560px;margin:60px auto;box-shadow:0 4px 20px rgba(0,0,0,0.1);
|
|
||||||
font-family:'Inter','Segoe UI',Arial,sans-serif;">
|
|
||||||
<div style="font-size:3em;margin-bottom:16px;">✅</div>
|
|
||||||
<h2 style="color:#262626;font-weight:700;margin-bottom:10px;">Request sent!</h2>
|
|
||||||
<p style="color:#777;line-height:1.6;">
|
|
||||||
Please check your email for the payment link and confirmation.<br>
|
|
||||||
New features will be active as soon as the payment is complete.
|
|
||||||
</p>
|
|
||||||
</div>`;
|
|
||||||
} catch (err) {
|
|
||||||
console.error(err);
|
|
||||||
alert(
|
|
||||||
"Something went wrong. Please try again or contact support.",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
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 ──────────────────────────────────────────────────────
|
// ── Wire buy buttons ──────────────────────────────────────────────────────
|
||||||
|
|||||||
Reference in New Issue
Block a user