4401// TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)4402// @ts-expect-error ST-2949_24403function tcart__openRestoredCart(restoredProducts) {4404tcart__saveRestoredProducts(restoredProducts);4405tcart__openCart();4406tcart__clearLostCartUrl();4407}4408// TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)4409// @ts-expect-error ST-2949_24410async function tcart__getProductsInfoById(products) {4411// @ts-expect-error ST-2949_2
var genUids = products.map(function (p) { return p['gen_uid']; }); try { var data = await t_cart__loadProductsInfoById(genUids); if (!data.products || data.products.length === 0) { return; } var newProducts = data.products; // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015) // @ts-expect-error ST-2949_2 var restoredProducts = []; // @ts-expect-error ST-2949_2 products.forEach(function (product) { // для каждого товара из брошенной корзины находим родительский товар со всей нужной информацией var newProductIdx = newProducts .map(function (x) { return x['uid']; }) .indexOf(parseInt(product['gen_uid'], 10)); var newProduct = newProducts[newProductIdx]; if (!newProduct) return; // получаем картинку на случай, если у варианта товара нет своей картинки var newProductGallery = ''; var newProductImg = ''; if (newProduct['gallery']) newProductGallery = JSON.parse(newProduct['gallery']); if (newProductGallery.length) { newProductImg = JSON.parse(newProduct['gallery'])[0].img; } // внутри родительского товара ищем вариант, который находится в брошенной корзине var editions = newProduct['editions']; var editionIdx = editions .map(function (x) { return x['uid']; }) .indexOf(parseInt(product['uid'], 10)); if (editionIdx < 0) { return; } var edition = editions[editionIdx]; if (!edition) { return; } // добавляем название и количество из брошенной корзины, картинку из полной информации // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551) // @ts-expect-error ST-2949_1 edition.gen_uid = product.gen_uid; // @ts-expect-error ST-2949_1 edition.name = product.name; edition.quantity = product.quantity; // @ts-expect-error ST-2949_1 edition.options = product.options; // @ts-expect-error ST-2949_1 edition.amount = product.quantity * product.price; if (!edition.img && newProductImg) edition.img = newProductImg; restoredProducts.push(edition); }); // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015) // @ts-expect-error ST-2949_2 tcart__restoreLostCart(restoredProducts); } catch (e) { console.error(e); }}/** * Получает элемент формы корзины * @returns {HTMLFormElement} */function tcart__form__getForm() { // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046) // @ts-expect-error ST-2949_5 return document.querySelector('.t706 .t-form');}/** * Получает элемент доставок * @returns {HTMLFormElement} */function tcart__form__getDeliveryWrapper() { // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046) // @ts-expect-error ST-2949_5