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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-cart-1.0.js

Код файла
Версия от 24.08.2026, 07:03:11 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
5001			if (typeof usedDiscounts[product.discountid] === 'undefined') {5002				usedDiscounts[product.discountid] = {5003					value: (product.amount - product.amount_withdiscount).toFixed(2) * 1,5004					typeid: Array.prototype.find.call(window.t_cart__discounts, function (discount) {5005						return discount.id === product.discountid;5006					}).typeid,5007				};5008			} else {5009				usedDiscounts[product.discountid].value +=5010					(product.amount - product.amount_withdiscount).toFixed(2) * 1;5011			}
История файла и сравнение версий
  • 24.08.2026, 07:03:11 · 56c3b845
5012
}
5013 });
5014
5015 // -Линейная/Дифференциальная- скидка от -кол-ва товаров/суммы заказа- : 100р
5016 var discountRulesArr = [];
5017 var discountRules = {
5018 0: {
5019 text:
5020 window.t_cart__browserLang == 'RU'
5021 ? 'Специальная скидка от кол-ва товаров'
5022 : 'Special discount from product amount',
5023 value: 0,
5024 },
5025 1: {
5026 text:
5027 window.t_cart__browserLang == 'RU'
5028 ? 'Специальная скидка от суммы заказа'
5029 : 'Special discount from total price',
5030 value: 0,
5031 },
5032 };
5033
5034 Object.keys(usedDiscounts).forEach(function (id) {
5035 var discountType = usedDiscounts[id].typeid; // 0,2 - линейная 1,3 - дифференциальная
5036 discountRules[discountType < 2 ? 0 : 1].value += usedDiscounts[id].value;
5037 });
5038
5039 Object.keys(discountRules).forEach(function (key) {
5040 if (discountRules[key].value !== 0) {
5041 discountRulesArr.push(
5042 discountRules[key].text +
5043 ': ' +
5044 (window.tcart['currency_txt_l'] ? window.tcart['currency_txt_l'] : '') +
5045 discountRules[key].value.toFixed(2) +
5046 (window.tcart['currency_txt_r'] ? window.tcart['currency_txt_r'] : '')
5047 );
5048 }
5049 });
5050
5051 var str =
5052 '' +
5053 '<span class="t706__cartwin-discounts__description-wrapper">' +
5054 '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16px" height="16px" viewBox="0 0 100 100" version="1.1"><defs><path d="M50,100 C22.3857625,100 0,77.6142375 0,50 C0,22.3857625 22.3857625,0 50,0 C77.6142375,0 100,22.3857625 100,50 C100,77.6142375 77.6142375,100 50,100 Z M58.315357,47.8754138 C64.89496,45.1601848 68.6565657,39.5064417 68.6565657,32.4846866 C68.6565657,22.841424 60.0015458,15.1818182 49.4949495,15.1818182 C41.3938959,15.1818182 34.1961467,19.7654779 31.4653335,26.6083919 L37.0379757,28.8322756 C38.8326304,24.3352021 43.7844087,21.1818182 49.4949495,21.1818182 C56.8399815,21.1818182 62.6565657,26.3294369 62.6565657,32.4846866 C62.6565657,37.0829994 60.3544491,40.5431111 56.0265483,42.3291218 L58.315357,47.8754138 Z M46.4949495,65.9659424 L52.4949495,65.9659424 C52.4949495,65.8347613 52.4965643,57.1867246 52.499763,57.0584416 C52.6251391,52.0302323 55.1839146,49.2186694 58.315357,47.8754138 L56.0265483,42.3291218 C50.3793252,44.7515403 46.6063369,49.847676 46.4973739,57.1228386 C46.4957596,57.2306251 46.4949495,65.8572009 46.4949495,65.9659424 Z M45.4949495,73.7777778 L45.4949495,83.2929293 L53.4949495,83.2929293 L53.4949495,73.7777778 L45.4949495,73.7777778 Z" id="path-1"/></defs><g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="Artboard-Copy-3"><mask id="mask-2" fill="white"><use xlink:href="#path-1"/></mask><use id="Combined-Shape" fill="#000000" xlink:href="#path-1"/></g></g></svg>' +
5055 '<ul class="t706__cartwin-discounts__description' +
5056 (discountRulesArr.length > 1 ? '' : ' t706__cartwin-discounts__description_single') +
5057 '">';
5058
5059 discountRulesArr.forEach(function (rule) {
5060 str += '<li>' + rule + '</li>';
5061 });
5062
5063 str += '</ul></span>';
5064
5065 return str;
5066}
5067
5068function tcart__calcPromocode(amount) {
5069 // если прокода нет, возвращаем тот же amount и удаляем старые поля промокода (если они есть)
5070 if (typeof window.tcart.promocode !== 'object') {
5071 delete window.tcart['prodamount_discountsum'];
5072 delete window.tcart['prodamount_withdiscount'];
5073
5074 return amount;
5075 }
5076
5077 // если промокод вроде и был, но нет правил на которые опираться, возвращаем тот же amount
5078 if (!(window.tcart.promocode.discountsum > 0) && !(window.tcart.promocode.discountpercent > 0)) {
5079 console.error('Cart Some error.');
5080 return amount;
5081 }
5082
5083 var prodamount_discountsum = 0;
5084 var prodamount_withdiscount = 0;
5085 var lastSingleId = false;
5086 var prodAmount = window.tcart.prodamount;
5087
5088 if (
5089 window.t_cart__discounts &&
5090 window.t_cart__discounts.length > 0 &&
5091 typeof window.tcart.prodamount_withdyndiscount !== 'undefined'
5092 ) {
5093 prodAmount = window.tcart.prodamount_withdyndiscount;
5094 }
5095
5096 window.tcart.products.forEach(function (product) {
5097 if (product.deleted === 'yes') return;
5098 if (Object.keys(product).length === 0) return;
5099
5100 var newPriceWithPromocode = '';
Предыдущие 100 строкСледующие 100 строк