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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-cart-1.0.js

Код файла
Версия от 24.08.2026, 07:03:11 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
4901							localStorage.setItem(4902								'tcart_discounts_sumrule',4903								JSON.stringify(window.sumpromowithdiscount)4904							);4905						localStorage.setItem('tcart_discounts', JSON.stringify(tcart__discounts));4906					} catch (e) {4907						console.error('Your web browser does not support storing a Discount data locally.');4908					}4909				}4910			} else if (typeof localStorage === 'object') {4911				try {4912
История файла и сравнение версий
  • 24.08.2026, 07:03:11 · 56c3b845
// сохраняем скидки в localStorage
4913 tcart__discounts = {
4914 time: Date.now(),
4915 discounts: [],
4916 };
4917 localStorage.setItem('tcart_discounts', JSON.stringify(tcart__discounts));
4918 } catch (e) {
4919 console.error('Your web browser does not support storing a Discount data locally.');
4920 }
4921 }
4922 }
4923 };
4924
4925 var onError = function (error) {
4926 if (
4927 error &&
4928 (error.status >= 500 ||
4929 error.status == 408 ||
4930 error.status == 410 ||
4931 error.status == 429 ||
4932 error.type === 'timeout')
4933 ) {
4934 if (typeof onError === 'function') {
4935 setTimeout(function () {
4936 onError();
4937 }, 5000);
4938 }
4939 } else {
4940 var text;
4941 if (error && error.responseText > '') {
4942 text = '[' + error.status + '] ' + error.responseText;
4943 } else if (error && error.statusText) {
4944 text = 'Error [' + error.status + ', ' + error.statusText + ']';
4945 } else {
4946 text = 'Error type [' + error.type + ']';
4947 }
4948
4949 console.info(text + '. Please, try again later.');
4950 }
4951 };
4952
4953 http.ontimeout = onError;
4954 http.onerror = onError;
4955
4956 http.timeout = 20000;
4957
4958 http.send(params);
4959}
4960
4961function tcart__insertDiscountsScript() {
4962 var fileName = 'tilda-cart-discounts-1.0';
4963 if (!document.getElementById('cart_discounts_script')) {
4964 var script = document.createElement('script');
4965 script.id = 'cart_discounts_script';
4966 script.type = 'text/javascript';
4967 script.src = 'https://static.tildacdn.' + tcart__getRootZone() + '/js/' + fileName + '.min.js';
4968 //script.src = 'http://127.0.0.1:8080/tildascripts/js/tilda-cart-discounts-1.0.js';
4969 script.onload = function () {
4970 console.info('executing discounts');
4971
4972 tcart__onFuncLoad('tcart__calcAmountWithDiscounts', function () {
4973 tcart__calcAmountWithDiscounts();
4974 });
4975 };
4976 script.onerror = function () {
4977 console.error('Failed to load tilda-cart-discounts: ', this.src);
4978 };
4979 document.head.appendChild(script);
4980
4981 var link = document.createElement('link');
4982 link.id = 'cart_discounts_style';
4983 link.rel = 'stylesheet';
4984 link.href = 'https://static.tildacdn.' + tcart__getRootZone() + '/css/' + fileName + '.min.css';
4985 //link.href = 'http://127.0.0.1:8080/css/tilda-cart-discounts-1.0.css';
4986 document.head.appendChild(link);
4987 } else {
4988 tcart__onFuncLoad('tcart__calcAmountWithDiscounts', function () {
4989 tcart__calcAmountWithDiscounts();
4990 });
4991 }
4992}
4993
4994function tcart__addDiscountInfo() {
4995 var usedDiscounts = {};
4996
4997 window.tcart.products.forEach(function (product) {
4998 if (product.deleted === 'yes') return;
4999 if (Object.keys(product).length === 0) return;
5000 if (product.discountid) {
Предыдущие 100 строкСледующие 100 строк