6801* @param {Options} options6802* @param {Array<Object>} optsValsBeforeChangedArr6803* @param {boolean} isChanged6804*6805* @returns {boolean} - доступна ли для покупки вариация товара6806*/6807function t_store_product_selectAvailableEdition(6808recid,6809product,6810el_product,6811options,6812optsValsBeforeChangedArr,
isChangedProduct) { var edition = optsValsBeforeChangedArr && optsValsBeforeChangedArr.length > 0 ? t_store_product_getFirstAvailableEditionData_forCertainVals( product.editions, optsValsBeforeChangedArr, el_product ) : t_store_product_getFirstAvailableEditionData(product.editions); if (!edition) { console.error('No available edition for uid = ' + product.uid + ' with selected options values'); return false; } var allrecords = document.getElementById('allrecords'); var isEditMode = allrecords && allrecords.getAttribute('data-tilda-mode') === 'edit'; var isAvailable = parseInt(edition.quantity, 10) > 0 || edition.quantity === ''; var isChanged = isChangedProduct; // change controls Array.prototype.forEach.call(product.editionOptions, function (curOption) { var value = edition[curOption.name]; var el_select = t_store_product_getEditionSelectEl(el_product, curOption); if (el_select) { var variant = el_select.querySelector('.js-product-edition-option-variants'); if (variant) { variant.value = (value || '').replace(/>/g, '>').replace(/</g, '<').replace(/\/g, '\\'); if (options.prodCard && options.prodCard.showOpts) { isChanged = true; // в новом edition случится замена изображения } } // Change custom options if available var el_custom_opts = el_select.querySelectorAll('.t-product__option-variants_custom'); function activateOptionItem(customOpt, value, isEditMode) { const el_items = customOpt.querySelectorAll('.t-product__option-item'); el_items.forEach(item => { const el_input = item.querySelector('.t-product__option-input'); if (!el_input) return; const normalizedValue = (value || '').replace(/&/g, '&'); if (el_input.value === normalizedValue) { item.classList.add('t-product__option-item_active'); setTimeout(() => { el_input.checked = true; if (!isEditMode) { el_input.click(); } }); if (options.prodCard && options.prodCard.showOpts) { isChanged = true; } } else { el_input.checked = false; item.classList.remove('t-product__option-item_active'); } }); } // Использование el_custom_opts.forEach(customOpt => activateOptionItem(customOpt, value, isEditMode)); } }); /* For not relevant products */ if (!el_product.classList.contains('js-product-relevant')) { /* Checking if the edition uid is in the url and if it is different from the current edition. If it is, it will set the edObj variable to the edition object. */ var urlParams = t_store_snippet_getJsonFromUrl(); var uid = urlParams.editionuid; var edObj; if (uid && document.querySelector('#rec' + recid + ' .js-product').getAttribute('data-product-uid') !== uid) { product.editions.forEach(function (edtn) { if (edtn.uid === uid) { edObj = edtn; } }); } if (edObj) { t_store_product_updateEdition(recid, el_product, edObj, product, options, isChanged); } else {