Bootcamp page: Reserve your seat now buys the bootcamp (product_id 12)

The three Reserve-your-seat CTAs posted to /support.html#contact. They now
run the same checkout path as the main page's Buy Now: a new page-local
static/buy.js mirrors script.js buyNow() (POST basket to
20.odoo4projects.com/shop/post_basket, clear=1, UTM cookies appended) and
binds .btn-buy via one delegated click handler. CTAs become
.btn-buy[data-id=12]; label unchanged. script.js and the homepage untouched.

The Price-and-booking section keeps a second, smaller link to
/support.html#contact so readers who have questions still have a fallback.
This commit is contained in:
oliver committed 2026-10-24 22:03:38 +00:00
1 parent b69e4ceaed
commit 45a3cc5398
2 files changed
+84 -3

No files matched your search

+79
View File
@@ -0,0 +1,79 @@
/* buy.js — page-local checkout helper.
*
* Mirrors `script.js` `buyNow()` — the main page's checkout path.
* If that changes, change this too.
*
* Loaded by pages that do not load `script.js` (e.g. the bootcamp page).
* Binds `.btn-buy` elements: <a class="btn-buy" data-id="12">…</a>.
*/
(function () {
'use strict';
/* ---- UTM tracking helpers (verbatim from script.js) ---- */
function getCookie(name) {
var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
return match ? decodeURIComponent(match[2]) : null;
}
function getStoredUTM() {
var utm = {};
var keys = ['source', 'medium', 'campaign'];
for (var i = 0; i < keys.length; i++) {
var val = getCookie('utm_' + keys[i]);
if (val) utm[keys[i]] = val;
}
return utm;
}
function appendToForm(form) {
var stored = getStoredUTM();
var keys = ['source', 'medium', 'campaign'];
for (var i = 0; i < keys.length; i++) {
if (stored[keys[i]]) {
var input = document.createElement('input');
input.type = 'hidden';
input.name = 'utm_' + keys[i];
input.value = stored[keys[i]];
form.appendChild(input);
}
}
}
/* ---- Buy Now — POST basket via form, opens checkout in new tab ---- */
window.buyNow = function (productId) {
var form = document.createElement('form');
form.method = 'POST';
form.action = 'https://20.odoo4projects.com/shop/post_basket';
form.target = '_blank';
form.style.display = 'none';
var basket = document.createElement('input');
basket.type = 'hidden';
basket.name = 'basket';
basket.value = JSON.stringify([{ product_id: productId, qty: 1 }]);
form.appendChild(basket);
var clear = document.createElement('input');
clear.type = 'hidden';
clear.name = 'clear';
clear.value = '1';
form.appendChild(clear);
appendToForm(form);
document.body.appendChild(form);
form.submit();
document.body.removeChild(form);
};
/* ---- Bind .btn-buy (delegated: same contract as script.js) ---- */
document.addEventListener('click', function (e) {
var btn = e.target.closest ? e.target.closest('.btn-buy') : null;
if (!btn) return;
var id = btn.getAttribute('data-id');
if (id) {
e.preventDefault();
window.buyNow(parseInt(id, 10));
}
});
})();