69016902// TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)6903// @ts-expect-error ST-2949_16904window.tcart.products.forEach(function (product) {6905if (product.deleted === 'yes') return;6906if (Object.keys(product).length === 0) return;6907if (product.discountid) {6908// TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)6909// @ts-expect-error ST-2949_26910if (typeof usedDiscounts[product.discountid] === 'undefined') {6911var discount = Array.prototype.find.call(window.t_cart__discounts, function (item) {
return item.id == product.discountid; }); // 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 usedDiscounts[product.discountid] = { // TODO ST-2949_6: operators / arithmetic / unintentional comparison (TS2362, TS2365, TS2367) // @ts-expect-error ST-2949_6 value: (product.amount - product.amount_withdiscount).toFixed(2) * 1, typeid: discount && discount.typeid, is_loyalty: !!(discount && discount.is_loyalty), }; } else { // 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 usedDiscounts[product.discountid].value += // TODO ST-2949_6: operators / arithmetic / unintentional comparison (TS2362, TS2365, TS2367) // @ts-expect-error ST-2949_6 (product.amount - product.amount_withdiscount).toFixed(2) * 1; } } }); // -Линейная/Дифференциальная- скидка от -кол-ва товаров/суммы заказа- : 100р var discountRulesArr = []; var discountRules = { 0: { text: window.t_cart__browserLang == 'RU' ? 'Специальная скидка от кол-ва товаров' : 'Special discount from product amount', value: 0, }, 1: { text: window.t_cart__browserLang == 'RU' ? 'Специальная скидка от суммы заказа' : 'Special discount from total price', value: 0, }, }; var loyaltyDiscount = { text: tcart_dict('loyaltyProgram'), value: 0, }; Object.keys(usedDiscounts).forEach(function (id) { // 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 usedDiscount = usedDiscounts[id]; if (usedDiscount.is_loyalty) { loyaltyDiscount.value += usedDiscount.value; return; } var discountType = usedDiscount.typeid; // 0,2 - линейная 1,3 - дифференциальная if (typeof discountType !== 'number') return; discountRules[discountType < 2 ? 0 : 1].value += usedDiscount.value; }); Object.keys(discountRules).forEach(function (key) { // 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 if (discountRules[key].value !== 0) { discountRulesArr.push( // @ts-expect-error ST-2949_2 discountRules[key].text + ': ' + // @ts-expect-error ST-2949_2 (window.tcart['currency_txt_l'] ? window.tcart['currency_txt_l'] : '') + // @ts-expect-error ST-2949_2 discountRules[key].value.toFixed(2) + // @ts-expect-error ST-2949_2 (window.tcart['currency_txt_r'] ? window.tcart['currency_txt_r'] : '') ); } }); var hasCatalogDiscount = discountRulesArr.length > 0; var hasLoyaltyDiscount = loyaltyDiscount.value !== 0; if (hasLoyaltyDiscount) { discountRulesArr.push( loyaltyDiscount.text + ': ' + // 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 (window.tcart['currency_txt_l'] ? window.tcart['currency_txt_l'] : '') + loyaltyDiscount.value.toFixed(2) + // @ts-expect-error ST-2949_2 (window.tcart['currency_txt_r'] ? window.tcart['currency_txt_r'] : '')