Public Access
All nine Buy forms on the bootcamp pages (EN/DE/ES, three each) posted product_id 12, which the shop resolves to 'Bootcamp - Q1-2026-eng'. The advertised cohort is Q1 2027 (starts Thu 21 Jan 2027), so a customer buying the 2027 bootcamp received the 2026 cohort. Both are 595.00 and neither cart was empty, so it went unnoticed; the form's info field reads 'Q1 2027, English' while the product was 2026. product_id 12 -> 17 in every bootcamp Buy form, all three languages. The info field is kept (it renders as the cart line description via sale.order.line.name, so it is read downstream); it is truthful. static/buy.js doc comment updated to match. Nothing else changed: plausible-event-name=Buy class, target=_blank form post, prices and layout untouched.
56 lines
2.1 KiB
JavaScript
56 lines
2.1 KiB
JavaScript
/* buy.js — page-local checkout helper (progressive enhancement).
|
|
*
|
|
* The checkout itself is a native <form method="post" target="_blank"> that posts
|
|
* basket=[{"product_id":17,"qty":1}] + clear=1 to
|
|
* https://20.odoo4projects.com/shop/post_basket. With JavaScript off it still works.
|
|
*
|
|
* This file only adds attribution: on submit it appends the utm_* hidden inputs
|
|
* from the cookies, then lets the native submit proceed (it never preventDefault).
|
|
*
|
|
* The UTM helpers mirror `script.js` `buyNow()` — the main page's checkout path.
|
|
* If that changes, change this too.
|
|
*/
|
|
(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]] && !form.elements['utm_' + keys[i]]) {
|
|
var input = document.createElement('input');
|
|
input.type = 'hidden';
|
|
input.name = 'utm_' + keys[i];
|
|
input.value = stored[keys[i]];
|
|
form.appendChild(input);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* ---- Progressive enhancement: add UTM inputs to the native basket form ----
|
|
Capture phase, so the inputs are in the form before the browser serialises it.
|
|
No preventDefault — the native POST proceeds untouched. */
|
|
document.addEventListener('submit', function (e) {
|
|
var form = e.target;
|
|
if (!form || form.tagName !== 'FORM') return;
|
|
if (!form.querySelector('input[name="basket"]')) return;
|
|
appendToForm(form);
|
|
}, true);
|
|
})();
|