Hoppa till innehåll
Visar alla 5 resultat
document.addEventListener('DOMContentLoaded', function () {
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
// Visa popup om cookie inte finns
if (!getCookie('customer_type')) {
const popupOpenBtn = document.querySelector('[data-wp-popup-open]'); // triggers popup
if (popupOpenBtn) popupOpenBtn.click();
}
// Spara valet
const privateBtn = document.getElementById('private_customer');
const businessBtn = document.getElementById('business_customer');
if (privateBtn) {
privateBtn.addEventListener('click', function () {
document.cookie = "customer_type=private; path=/; max-age=" + 60 * 60 * 24 * 30;
location.reload();
});
}
if (businessBtn) {
businessBtn.addEventListener('click', function () {
document.cookie = "customer_type=business; path=/; max-age=" + 60 * 60 * 24 * 30;
location.reload();
});
}
});