Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-cart-1.1.js

Код файла
Версия от 04.12.2026, 04:03:54 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
7101			productAmount = product.amount_withdiscount;7102		}7103 7104		if (product.portion) {7105			productPrice = productPrice / portion;7106			hasPortion = true;7107 7108			if (window.showdiscountdata)7109				console.info('start price for one portion (' + product.portion + ') - ' + productPrice);7110		}7111 7112		// рассчитываем новую стоимость
История файла и сравнение версий
  • 04.12.2026, 04:03:54 · 56c3b845
7113 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
7114 // @ts-expect-error ST-2949_1
7115 if (window.tcart.promocode.discountsum > 0) {
7116 // @ts-expect-error ST-2949_1
7117 newPriceWithPromocode = tcart_ceil(productPrice * (1 - window.tcart.promocode.discountsum / prodAmount));
7118 // @ts-expect-error ST-2949_1
7119 } else if (window.tcart.promocode.discountpercent > 0) {
7120 // @ts-expect-error ST-2949_1
7121 var curDiscountInt = 1 - window.tcart.promocode.discountpercent / 100;
7122 // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)
7123 // @ts-expect-error ST-2949_5
7124 newPriceWithPromocode = tcart_ceil(productPrice * curDiscountInt);
7125 }
7126
7127 if (product.quantity * 1 === 1 && !product.portion) lastSingleId = true;
7128
7129 if (hasPortion) {
7130 if (window.showdiscountdata)
7131 console.info('For one portion: ' + productPrice + ' -> ' + newPriceWithPromocode);
7132 // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)
7133 // @ts-expect-error ST-2949_5
7134 newPriceWithPromocode = tcart_ceil(newPriceWithPromocode * portion);
7135 }
7136
7137 // TODO ST-2949_6: operators / arithmetic / unintentional comparison (TS2362, TS2365, TS2367)
7138 // @ts-expect-error ST-2949_6
7139 var newAmountWithPromocode = tcart_ceil(newPriceWithPromocode * product.quantity);
7140
7141 prodamount_discountsum += tcart_ceil(productAmount - newAmountWithPromocode);
7142 prodamount_withdiscount = tcart_ceil(prodamount_withdiscount * 1 + newAmountWithPromocode);
7143
7144 if (window.showdiscountdata)
7145 console.info(
7146 (hasPortion ? productPrice * product.portion : productPrice) +
7147 ' -> ' +
7148 newPriceWithPromocode +
7149 ' = ' +
7150 prodamount_discountsum
7151 );
7152 });
7153
7154 prodamount_discountsum = tcart_ceil(prodamount_discountsum);
7155
7156 // если скидка была в валюте, то проверяем
7157 // совпадает ли первоначальная скидка с тем что получилось
7158 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
7159 // @ts-expect-error ST-2949_1
7160 if (window.tcart.promocode.discountsum > 0) {
7161 // @ts-expect-error ST-2949_1
7162 var remainder = window.tcart.promocode.discountsum * 1 - prodamount_discountsum * 1;
7163
7164 if (window.showdiscountdata)
7165 // @ts-expect-error ST-2949_1
7166 console.info(window.tcart.promocode.discountsum, prodamount_discountsum, remainder);
7167
7168 // если в корзине имеется продукт с quantity = 1 и у нас есть остаток, то добавляем этот остаток и пересчитываем скидку
7169 if (lastSingleId && remainder > 0) {
7170 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
7171 // @ts-expect-error ST-2949_1
7172 prodamount_withdiscount = tcart_ceil(amount - window.tcart.promocode.discountsum);
7173 // @ts-expect-error ST-2949_1
7174 prodamount_discountsum = window.tcart.promocode.discountsum;
7175 }
7176 }
7177
7178 if (prodamount_withdiscount < 0) {
7179 prodamount_withdiscount = 0;
7180 }
7181
7182 // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)
7183 // @ts-expect-error ST-2949_2
7184 window.tcart['prodamount_discountsum'] = prodamount_discountsum;
7185 // @ts-expect-error ST-2949_2
7186 window.tcart['prodamount_withdiscount'] = prodamount_withdiscount;
7187 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
7188 // @ts-expect-error ST-2949_1
7189 window.tcart.promocode['prodamount_discountsum'] = prodamount_discountsum;
7190
7191 var promocodePriceEl = document.querySelector(
7192 '.t-inputpromocode__wrapper .t706__cartwin-prodamount-price:nth-last-child(2)'
7193 );
7194
7195 // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)
7196 // @ts-expect-error ST-2949_5
7197 if (promocodePriceEl) promocodePriceEl.innerHTML = prodamount_discountsum;
7198
7199 return prodamount_withdiscount;
7200}
Предыдущие 100 строкСледующие 100 строк