(function () { // add to basket window.insideCustomAddToBasket = function(basket) { if (basket) { basket = typeof basket === "string" ? JSON.parse(basket) : basket; if (basket.type === 'cto') { window.location = window.location.origin + "/" + lmd.cc + "/" + lmd.language + "/configurator/cto/index.html?bundleId=" + basket.id; } else { fetch("https://openapi.lenovo.com/" + lmd.cc + "/" + lmd.language + "/api/cart/item", { method: 'POST', body: 'qty=' + basket.quantity + '&productCode=' + basket.id, credentials: "include", headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, }).then(response => response.json()).then(function(response) { insideAPI.post("/api/visitor/updateproductrecommendation", { sku: basket.id, conversationid: insideFrontInterface.currentChatId }); if (response && response.data && response.data.guid) { window.location = window.location.origin + "/" + lmd.cc + "/" + lmd.language + "/pb/index.html?mainCode=" + basket.id + "&guid=" + response.data.guid; } else { window.location = window.location.origin + "/" + lmd.cc + "/" + lmd.language + "/cart"; } }).catch(error => { console.error(error); }); } } } })();