Add direct Odoo shop buy buttons: POST basket + open cart in new window

This commit is contained in:
2026-08-21 21:50:00 +00:00
parent 09f8b6100f
commit 284f59f863
2 changed files with 16 additions and 3 deletions
+13
View File
@@ -621,3 +621,16 @@ var si = 0,
success.style.display = 'block';
});
})();
/* Buy Now — POST product to Odoo shop basket, open cart in new window */
window.buyNow = function (productId) {
fetch('https://ODOO4projects.com/shop/post_basket', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
basket: [{ product_id: productId, qty: 1 }],
clear: '1'
})
}).catch(function () { /* ignore CORS / network errors */ });
window.open('https://ODOO4projects.com/shop/cart', '_blank');
};