Fermeture
-- Faire un choix -- Sans cadenas Avec Cadenas +
130,00 Dhs
document.addEventListener('DOMContentLoaded', function () {
function formatPrice(price) {
return price.toLocaleString('fr-FR', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
}
function extractOptionPrice(option) {
if (!option || !option.textContent) return 0;
var m = option.textContent.match(/\+\s*([\d\s,\.]+)/);
if (!m || !m[1]) return 0;
var raw = m[1].replace(/\s/g, '').replace(',', '.');
var val = parseFloat(raw);
return isNaN(val) ? 0 : val;
}
function ensureHtSuffix(root) {
root.querySelectorAll('.custom-amount').forEach(function (amountEl) {
if (!amountEl.querySelector('.ht-suffix')) {
var s = document.createElement('span');
s.className = 'ht-suffix';
s.textContent = ' HT';
amountEl.appendChild(s);
}
});
}
function observePriceContainer(node) {
if (!node || node.dataset.htObserved === '1') return;
node.dataset.htObserved = '1';
ensureHtSuffix(node);
var mo = new MutationObserver(function () {
ensureHtSuffix(node);
});
mo.observe(node, { childList: true, subtree: true });
}
function hookExisting() {
document.querySelectorAll(
'.price-box.price-final_price, [data-role="priceBox"], .custom-price-wrapper'
).forEach(observePriceContainer);
}
var globalObserver = new MutationObserver(function (mutations) {
mutations.forEach(function (m) {
m.addedNodes.forEach(function (n) {
if (!(n instanceof Element)) return;
if (
n.matches &&
(n.matches('.price-box.price-final_price') ||
n.matches('[data-role="priceBox"]') ||
n.matches('.custom-price-wrapper'))
) {
observePriceContainer(n);
}
n.querySelectorAll &&
n.querySelectorAll('.price-box.price-final_price, [data-role="priceBox"], .custom-price-wrapper')
.forEach(observePriceContainer);
});
});
});
globalObserver.observe(document.body, { childList: true, subtree: true });
function updateFinalPrice() {
var finalAmount = document.querySelector('.custom-amount[data-price-type="finalPrice"]');
if (!finalAmount) return;
var priceTextEl = finalAmount.querySelector('.price .price') || finalAmount.querySelector('.price');
if (!priceTextEl) return;
var wrapper = finalAmount.closest('.custom-price-wrapper');
var basePrice = parseFloat(wrapper && wrapper.getAttribute('data-base-price')) || 0;
var total = basePrice;
document.querySelectorAll('select.product-custom-option').forEach(function (select) {
var opt = select.options[select.selectedIndex];
total += extractOptionPrice(opt);
});
priceTextEl.textContent = formatPrice(total) + '\u00A0Dhs';
if (wrapper) wrapper.setAttribute('data-current-price', String(total));
if (wrapper) ensureHtSuffix(wrapper);
}
document.querySelectorAll('select.product-custom-option').forEach(function (select) {
select.addEventListener('change', function () {
updateFinalPrice();
document.querySelectorAll(
'.price-box.price-final_price, [data-role="priceBox"], .custom-price-wrapper'
).forEach(ensureHtSuffix);
});
});
hookExisting();
updateFinalPrice();
ensureHtSuffix(document);
});
Fermeture Numérique +
150,00 Dhs
document.addEventListener('DOMContentLoaded', function () {
function formatPrice(price) {
return price.toLocaleString('fr-FR', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
}
function extractOptionPrice(option) {
if (!option || !option.textContent) return 0;
var m = option.textContent.match(/\+\s*([\d\s,\.]+)/);
if (!m || !m[1]) return 0;
var raw = m[1].replace(/\s/g, '').replace(',', '.');
var val = parseFloat(raw);
return isNaN(val) ? 0 : val;
}
function ensureHtSuffix(root) {
root.querySelectorAll('.custom-amount').forEach(function (amountEl) {
if (!amountEl.querySelector('.ht-suffix')) {
var s = document.createElement('span');
s.className = 'ht-suffix';
s.textContent = ' HT';
amountEl.appendChild(s);
}
});
}
function observePriceContainer(node) {
if (!node || node.dataset.htObserved === '1') return;
node.dataset.htObserved = '1';
ensureHtSuffix(node);
var mo = new MutationObserver(function () {
ensureHtSuffix(node);
});
mo.observe(node, { childList: true, subtree: true });
}
function hookExisting() {
document.querySelectorAll(
'.price-box.price-final_price, [data-role="priceBox"], .custom-price-wrapper'
).forEach(observePriceContainer);
}
var globalObserver = new MutationObserver(function (mutations) {
mutations.forEach(function (m) {
m.addedNodes.forEach(function (n) {
if (!(n instanceof Element)) return;
if (
n.matches &&
(n.matches('.price-box.price-final_price') ||
n.matches('[data-role="priceBox"]') ||
n.matches('.custom-price-wrapper'))
) {
observePriceContainer(n);
}
n.querySelectorAll &&
n.querySelectorAll('.price-box.price-final_price, [data-role="priceBox"], .custom-price-wrapper')
.forEach(observePriceContainer);
});
});
});
globalObserver.observe(document.body, { childList: true, subtree: true });
function updateFinalPrice() {
var finalAmount = document.querySelector('.custom-amount[data-price-type="finalPrice"]');
if (!finalAmount) return;
var priceTextEl = finalAmount.querySelector('.price .price') || finalAmount.querySelector('.price');
if (!priceTextEl) return;
var wrapper = finalAmount.closest('.custom-price-wrapper');
var basePrice = parseFloat(wrapper && wrapper.getAttribute('data-base-price')) || 0;
var total = basePrice;
document.querySelectorAll('select.product-custom-option').forEach(function (select) {
var opt = select.options[select.selectedIndex];
total += extractOptionPrice(opt);
});
priceTextEl.textContent = formatPrice(total) + '\u00A0Dhs';
if (wrapper) wrapper.setAttribute('data-current-price', String(total));
if (wrapper) ensureHtSuffix(wrapper);
}
document.querySelectorAll('select.product-custom-option').forEach(function (select) {
select.addEventListener('change', function () {
updateFinalPrice();
document.querySelectorAll(
'.price-box.price-final_price, [data-role="priceBox"], .custom-price-wrapper'
).forEach(ensureHtSuffix);
});
});
hookExisting();
updateFinalPrice();
ensureHtSuffix(document);
});
Epaisseur de Tole :
-- Faire un choix -- 7/10e 8/10e +
150,00 Dhs
document.addEventListener('DOMContentLoaded', function () {
function formatPrice(price) {
return price.toLocaleString('fr-FR', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
}
function extractOptionPrice(option) {
if (!option || !option.textContent) return 0;
var m = option.textContent.match(/\+\s*([\d\s,\.]+)/);
if (!m || !m[1]) return 0;
var raw = m[1].replace(/\s/g, '').replace(',', '.');
var val = parseFloat(raw);
return isNaN(val) ? 0 : val;
}
function ensureHtSuffix(root) {
root.querySelectorAll('.custom-amount').forEach(function (amountEl) {
if (!amountEl.querySelector('.ht-suffix')) {
var s = document.createElement('span');
s.className = 'ht-suffix';
s.textContent = ' HT';
amountEl.appendChild(s);
}
});
}
function observePriceContainer(node) {
if (!node || node.dataset.htObserved === '1') return;
node.dataset.htObserved = '1';
ensureHtSuffix(node);
var mo = new MutationObserver(function () {
ensureHtSuffix(node);
});
mo.observe(node, { childList: true, subtree: true });
}
function hookExisting() {
document.querySelectorAll(
'.price-box.price-final_price, [data-role="priceBox"], .custom-price-wrapper'
).forEach(observePriceContainer);
}
var globalObserver = new MutationObserver(function (mutations) {
mutations.forEach(function (m) {
m.addedNodes.forEach(function (n) {
if (!(n instanceof Element)) return;
if (
n.matches &&
(n.matches('.price-box.price-final_price') ||
n.matches('[data-role="priceBox"]') ||
n.matches('.custom-price-wrapper'))
) {
observePriceContainer(n);
}
n.querySelectorAll &&
n.querySelectorAll('.price-box.price-final_price, [data-role="priceBox"], .custom-price-wrapper')
.forEach(observePriceContainer);
});
});
});
globalObserver.observe(document.body, { childList: true, subtree: true });
function updateFinalPrice() {
var finalAmount = document.querySelector('.custom-amount[data-price-type="finalPrice"]');
if (!finalAmount) return;
var priceTextEl = finalAmount.querySelector('.price .price') || finalAmount.querySelector('.price');
if (!priceTextEl) return;
var wrapper = finalAmount.closest('.custom-price-wrapper');
var basePrice = parseFloat(wrapper && wrapper.getAttribute('data-base-price')) || 0;
var total = basePrice;
document.querySelectorAll('select.product-custom-option').forEach(function (select) {
var opt = select.options[select.selectedIndex];
total += extractOptionPrice(opt);
});
priceTextEl.textContent = formatPrice(total) + '\u00A0Dhs';
if (wrapper) wrapper.setAttribute('data-current-price', String(total));
if (wrapper) ensureHtSuffix(wrapper);
}
document.querySelectorAll('select.product-custom-option').forEach(function (select) {
select.addEventListener('change', function () {
updateFinalPrice();
document.querySelectorAll(
'.price-box.price-final_price, [data-role="priceBox"], .custom-price-wrapper'
).forEach(ensureHtSuffix);
});
});
hookExisting();
updateFinalPrice();
ensureHtSuffix(document);
});