1101if (imgLinkArr[0] && imgLinkArr[1]) {1102if (imgLinkArr[0] == 'image' && imgLinkArr[1].indexOf('.tildacdn.') > 0) {1103img = imgLinkArr[1];1104}1105}1106}1107}11081109if (recid == '') {1110recid = cartBtn.closest('.r')?.getAttribute('id')1111? cartBtn.closest('.r')?.getAttribute('id')?.replace('rec', '')1112
: ''; } } } var productElement = cartBtn.closest('.js-product'); if (productElement) { if (name == '') { var elementName = productElement.querySelector('.js-product-name'); name = elementName ? elementName.textContent.trim() : ''; } var currentPrice = typeof cleanedPrice === 'undefined' ? price : cleanedPrice; if (currentPrice == '' || currentPrice == 0) { var elementPrice = productElement.querySelector('.js-product-price'); if (elementPrice) { if ( elementPrice.classList.contains('js-catalog-prod-price-range-val') || elementPrice.classList.contains('js-store-prod-price-range-val') ) { price = elementPrice.getAttribute('data-product-price-range-val'); } else { price = elementPrice.textContent; } } // Без элемента цены очищается текущее значение, как раньше cleanedPrice = tcart__cleanPrice(elementPrice ? price : currentPrice); } if (img == '') { if (productElement.getAttribute('data-product-img')) { img = productElement.getAttribute('data-product-img'); } else { var imgDiv = productElement.querySelector('.js-product-img'); if (imgDiv) { var original = imgDiv.getAttribute('data-original') || ''; if (original.length > 0) { img = original; } else if (imgDiv.tagName == 'IMG') { img = imgDiv.getAttribute('src'); } else if (imgDiv.tagName == 'DIV') { img = ''; // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015) // @ts-expect-error ST-2949_2 var imgCss = getComputedStyle(imgDiv)['background-image']; if (imgCss) { img = imgCss.replace('url(', '').replace(')', '').replace(/"/gi, ''); } } } } } if (lid == '') { lid = productElement.getAttribute('data-product-lid') || ''; } if (uid == '') { uid = productElement.getAttribute('data-product-uid') || ''; } if (recid == '') { var recidAttr = productElement.closest('.r').getAttribute('id'); recid = recidAttr ? recidAttr.replace('rec', '') : ''; } if (inv == '') { inv = productElement.getAttribute('data-product-inv') || ''; } unit = productElement.getAttribute('data-product-unit') || ''; portion = productElement.getAttribute('data-product-portion') || ''; single = productElement.getAttribute('data-product-single') || ''; // варианты товара (с разными свойствами) var editionOptionsElements = productElement.querySelectorAll('.js-product-edition-option'); Array.prototype.forEach.call(editionOptionsElements, function (optionsElement) { var optionName = optionsElement.querySelector('.js-product-edition-option-name').textContent; var selectedOption = optionsElement.querySelector('option:checked'); if (selectedOption) { var optionVariant = selectedOption.value; if (optionName && optionVariant) { var optionObj = {}; if (optionName != '') { optionName = tcart__escapeHtml(optionName); } if (optionVariant != '') { optionVariant = tcart__escapeHtml(optionVariant); optionVariant = optionVariant.replace(/(?:\r\n|\r|\n)/g, ''); } if (optionName.length > 1 && optionName.slice(-1) == ':') { optionName = optionName.slice(0, -1); }