function setReturnFee() { const currentHost = window.location.host; const domainParts = currentHost.split('.'); const brandCode = domainParts.length > 2 ? domainParts[1].toLowerCase() : domainParts[0].toLowerCase(); const currentPath = window.location.pathname.toLowerCase(); const pathParts = currentPath.split('/').filter(Boolean); let languageCountryCode = ''; // Improved logic to support various URL structures for (let part of pathParts) { if (/^[a-z]{2}-[a-z0-9]{2,3}$/i.test(part)) { languageCountryCode = part; break; } } if (!languageCountryCode) { languageCountryCode = 'default'; } console.log("Brand Code: " + brandCode); console.log("Language-Country Code: " + languageCountryCode); const returnFeeMap = { "fr-fr": { "annarr": "2.99 €", "aprelclothing": "2.99 €", "bianco": "1.99 €", "jackjones": "2.99 €", "portlandouterwear": "2.99 €", "lilatelier": "1.99 €", "mamalicious": "2.99 €", "nameit": "1.99 €", "noisymay": "2.95 €", "objectci": "2.99 €", "only": "2.95 €", "onlyandsons": "2.95 €", "jdy": "2.95 €", "pieces": "2.99 €", "royaldenimdivision": "2.99 €", "rougeedit": "2.99 €", "selected": "2.99 €", "veromoda": "2.99 €", "vila": "2.99 €", "y-a-s": "2.99 €" }, "fr-be": { "annarr": "1.99 €", "aprelclothing": "2.99 €", "bianco": "1.99 €", "jackjones": "2.99 €", "portlandouterwear": "2.99 €", "lilatelier": "1.99 €", "mamalicious": "2.99 €", "nameit": "1.99 €", "noisymay": "2.95 €", "objectci": "2.99 €", "only": "2.95 €", "onlyandsons": "2.99 €", "jdy": "2.99 €", "pieces": "2.99 €", "royaldenimdivision": "2.99 €", "rougeedit": "2.99 €", "selected": "1.99 €", "thefounded": "1.99 €", "veromoda": "2.99 €", "vila": "2.99 €", "y-a-s": "2.99 €" }, "fr-ch": { "annarr": "1.99 CHF", "aprelclothing": "1.99 CHF", "bianco": "1.99 CHF", "jackjones": "1.99 CHF", "portlandouterwear": "1.99 CHF", "lilatelier": "1.99 CHF", "mamalicious": "2.99 CHF", "nameit": "1.99 CHF", "noisymay": "2.95 CHF", "objectci": "2.99 CHF", "only": "2.95 CHF", "onlyandsons": "2.99 CHF", "jdy": "2.99 CHF", "pieces": "2.99 CHF", "royaldenimdivision": "1.99 CHF", "rougeedit": "2.99 CHF", "selected": "1.99 CHF", "veromoda": "2.99 CHF", "vila": "2.99 CHF", "y-a-s": "2.99 CHF" }, "fr-lu": { "aprelclothing": "2.99 €", "jackjones": "2.99 €", "portlandouterwear": "2.99 €", "royaldenimdivision": "2.99 €", "only": "2.95 €", "onlyandsons": "2.95 €", "objectci": "2.99 €", "lilatelier": "2.99 €", "nameit": "2.99 €", "veromoda": "2.99 €" }, "fr-001": { "aprelclothing": "2.99 €", "jackjones": "2.99 €", "portlandouterwear": "2.99 €", "royaldenimdivision": "2.99 €", "veromoda": "3.99 €", "only": "6.99 €", "onlyandsons": "6.99 €", "jdy": "6.99 €" }, "fr-ma": { "aprelclothing": "17.99 €", "jackjones": "17.99 €", "portlandouterwear": "17.99 €", "royaldenimdivision": "17.99 €" }, "fr-dz": { "aprelclothing": "17.99 €", "jackjones": "17.99 €", "portlandouterwear": "17.99 €", "royaldenimdivision": "17.99 €" }, "fr-tn": { "aprelclothing": "17.99 €", "jackjones": "17.99 €", "portlandouterwear": "17.99 €", "royaldenimdivision": "17.99 €" }, "fr-ca": { "only": "9,95$", "jackjones": "9,95$", "veromoda": "9,95$" }, "default": { "default": "(erreur)" } }; const countryFees = returnFeeMap[languageCountryCode] || returnFeeMap["default"]; const returnFee = countryFees[brandCode] || countryFees["default"]; console.log("Country Fees: " + JSON.stringify(countryFees)); console.log("Return Fee: " + returnFee); const returnInfoElement = document.getElementById("return-info"); returnInfoElement.textContent = `Si vous utilisez notre étiquette de retour pour retourner vos articles, des frais de ${returnFee} seront déduits de votre remboursement. Nous facturons les frais de retour pour chaque commande retournée. Vous êtes responsable du retour de l'article (ou des articles).`; } setReturnFee();