5001if (typeof usedDiscounts[product.discountid] === 'undefined') {5002usedDiscounts[product.discountid] = {5003value: (product.amount - product.amount_withdiscount).toFixed(2) * 1,5004typeid: Array.prototype.find.call(window.t_cart__discounts, function (discount) {5005return discount.id === product.discountid;5006}).typeid,5007};5008} else {5009usedDiscounts[product.discountid].value +=5010(product.amount - product.amount_withdiscount).toFixed(2) * 1;5011}
} }); // -Линейная/Дифференциальная- скидка от -кол-ва товаров/суммы заказа- : 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, }, }; Object.keys(usedDiscounts).forEach(function (id) { var discountType = usedDiscounts[id].typeid; // 0,2 - линейная 1,3 - дифференциальная discountRules[discountType < 2 ? 0 : 1].value += usedDiscounts[id].value; }); Object.keys(discountRules).forEach(function (key) { if (discountRules[key].value !== 0) { discountRulesArr.push( discountRules[key].text + ': ' + (window.tcart['currency_txt_l'] ? window.tcart['currency_txt_l'] : '') + discountRules[key].value.toFixed(2) + (window.tcart['currency_txt_r'] ? window.tcart['currency_txt_r'] : '') ); } }); var str = '' + '<span class="t706__cartwin-discounts__description-wrapper">' + '<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>' + '<ul class="t706__cartwin-discounts__description' + (discountRulesArr.length > 1 ? '' : ' t706__cartwin-discounts__description_single') + '">'; discountRulesArr.forEach(function (rule) { str += '<li>' + rule + '</li>'; }); str += '</ul></span>'; return str;}function tcart__calcPromocode(amount) { // если прокода нет, возвращаем тот же amount и удаляем старые поля промокода (если они есть) if (typeof window.tcart.promocode !== 'object') { delete window.tcart['prodamount_discountsum']; delete window.tcart['prodamount_withdiscount']; return amount; } // если промокод вроде и был, но нет правил на которые опираться, возвращаем тот же amount if (!(window.tcart.promocode.discountsum > 0) && !(window.tcart.promocode.discountpercent > 0)) { console.error('Cart Some error.'); return amount; } var prodamount_discountsum = 0; var prodamount_withdiscount = 0; var lastSingleId = false; var prodAmount = window.tcart.prodamount; if ( window.t_cart__discounts && window.t_cart__discounts.length > 0 && typeof window.tcart.prodamount_withdyndiscount !== 'undefined' ) { prodAmount = window.tcart.prodamount_withdyndiscount; } window.tcart.products.forEach(function (product) { if (product.deleted === 'yes') return; if (Object.keys(product).length === 0) return; var newPriceWithPromocode = '';