Некодим© 2020-2026 Некодим
Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.
// сохраняем скидки в localStorage
4913 tcart__discounts = {4917 localStorage.setItem('tcart_discounts', JSON.stringify(tcart__discounts));4919 console.error('Your web browser does not support storing a Discount data locally.');4925 var onError = function (error) {4928 (error.status >= 500 ||4929 error.status == 408 ||4930 error.status == 410 ||4931 error.status == 429 ||4932 error.type === 'timeout')4934 if (typeof onError === 'function') {4935 setTimeout(function () {4941 if (error && error.responseText > '') {4942 text = '[' + error.status + '] ' + error.responseText;4943 } else if (error && error.statusText) {4944 text = 'Error [' + error.status + ', ' + error.statusText + ']';4946 text = 'Error type [' + error.type + ']';4949 console.info(text + '. Please, try again later.');4953 http.ontimeout = onError;4954 http.onerror = onError;4956 http.timeout = 20000;4961 function 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');4972 tcart__onFuncLoad('tcart__calcAmountWithDiscounts', function () {4973 tcart__calcAmountWithDiscounts();4976 script.onerror = function () {4977 console.error('Failed to load tilda-cart-discounts: ', this.src);4979 document.head.appendChild(script);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);4988 tcart__onFuncLoad('tcart__calcAmountWithDiscounts', function () {4989 tcart__calcAmountWithDiscounts();4994 function tcart__addDiscountInfo() {4995 var usedDiscounts = {};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) {