LIVRAISON GRATUITE À PARTIR DE 10 000 DA ACTIFS CONCENTRÉS · DERMATOLOGIQUEMENT TESTÉS LIVRAISON SUR 69 WILAYAS CONSEIL DERMATOLOGIQUE SOUS 24H LIVRAISON GRATUITE À PARTIR DE 10 000 DA ACTIFS CONCENTRÉS · DERMATOLOGIQUEMENT TESTÉS LIVRAISON SUR 69 WILAYAS CONSEIL DERMATOLOGIQUE SOUS 24H
// server-side which the PHP gettext filter doesn't reach (different template
// call). DOM-swap belt-and-suspenders fix.
function fixCheckoutLabels() {
var isAR = document.body.classList.contains('translatepress-ar');
// FR / EN → "Terminer l'achat" (FR side).
// AR side: WoodMart's "Sortie de caisse" was machine-translated to
// "تسجيل الخروج" (literally "Sign out / Log out") — wrong context.
// Force the correct AR commerce verb: "إتمام الشراء" (complete the purchase).
var swaps = isAR ? {
'تسجيل الخروج': 'إتمام الشراء',
'Sortie de caisse': 'إتمام الشراء',
'Procéder au paiement': 'إتمام الشراء',
"Terminer l'achat": 'إتمام الشراء',
"Terminer l’achat": 'إتمام الشراء',
'Proceed to checkout': 'إتمام الشراء',
'Proceed to Checkout': 'إتمام الشراء'
} : {
'Sortie de caisse': "Terminer l'achat",
'Procéder au paiement': "Terminer l'achat",
'Proceed to checkout': "Terminer l'achat",
'Proceed to Checkout': "Terminer l'achat"
};
document.querySelectorAll('span, a, button').forEach(function (el) {
// Only act on leaf-ish nodes (avoid nested replacements)
if (el.children.length > 0 && el.firstElementChild.tagName !== 'I') return;
var t = (el.textContent || '').trim();
if (swaps[t]) el.textContent = swaps[t];
});
}
fixCheckoutLabels();
window.addEventListener('load', fixCheckoutLabels);
document.addEventListener('updated_cart_totals', fixCheckoutLabels);
document.addEventListener('updated_wc_div', fixCheckoutLabels);
setTimeout(fixCheckoutLabels, 500);
setTimeout(fixCheckoutLabels, 1500);
setTimeout(fixCheckoutLabels, 3000);
// Round 10.8c — TP renders AR text AFTER initial load + setTimeout passes,
// so the AR "تسجيل الخروج" can land in DOM after our swap fired. Use a
// MutationObserver on the cart page that re-fires the swap on any DOM change.
if (/\/cart\/|\/checkout\//.test(location.pathname)) {
var mo = new MutationObserver(function () { fixCheckoutLabels(); });
mo.observe(document.body, { childList: true, subtree: true, characterData: true });
setTimeout(function () { mo.disconnect(); }, 8000);
}
})();