function CmdcReconvertInit() { var appBaseUrl = 'https://reconvert.cmdcbv.app'; var responseData; var containerSelector = '\u0023gui\u002Dwrapper'; function addLanguageToUrl(url) { var urlParts = document.location.pathname.split('/'); if (urlParts[1].length == 2) { return "/" + urlParts[1] + url; } else { return url; } } function getView() { var xhr = new XMLHttpRequest(); xhr.open('GET', appBaseUrl + '/public/ls/' + responseData.shop.id + '/getThankYou?orderId=' + responseData.order.information.id + '&language=' + responseData.shop.language); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { var container = $(xhr.response); $(containerSelector).before(container); } } xhr.send(); } var xhr = new XMLHttpRequest(); xhr.open('GET', addLanguageToUrl('/checkout/thankyou/?format=json')); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if (xhr.status === 200) { responseData = JSON.parse(xhr.response); if (document.readyState === "complete" || document.readyState === "interactive" || document.readyState === "loaded") { getView(); } else { document.addEventListener("DOMContentLoaded", function () { getView(); }); } } else { console.error(xhr.statusText); } } } xhr.send(); } if (document.location.pathname.indexOf('/checkout/thankyou/') > -1) { CmdcReconvertInit(); }