5401if (bgColor) {5402const productOldPriceColor = options.price.colorOld;5403t_store_applyContrastColorIfNecessary(productOldPrice, productOldPriceColor, bgColor);5404}5405}54065407/**5408* Устанавливает стили для опций товара в сниппете5409* @param {string} recid - ID записи5410* @param {TildaStoreOptions} options - Объект настроек5411*/5412function t_store_setProductOptionsStyles(recid, options) {
if (!options.options_typo) return; let typoWithoutShadow; try { typoWithoutShadow = JSON.parse(options.options_typo); } catch (e) { console.error('Error when parse options_typo parse error', e); return; } delete typoWithoutShadow.shadowsize; delete typoWithoutShadow.shadowopacity; const typoWithoutShadowJSON = JSON.stringify(typoWithoutShadow); const selector = '.t-product__option-title:not(.t-product__option-title_select):not(.t-product__option-title_radio):not(.t-product__option-title_buttons)'; t_store_parseTypoStylesConfig(recid, selector, options.options_typo, 'js-store-options-title-typo-styles-' + recid); if (options.descr_typo) { try { const descrColor = JSON.parse(options.descr_typo).color; const optionsColor = JSON.parse(options.options_typo).color; const style = t_store_option_getStyleInSnippet(descrColor, optionsColor); if (style !== '') { const cssRule = `#rec${recid} ${selector} { ${style}; }`; t_store_createСssStyleTag('js-store-options-title-color-rewrite-typo-styles-' + recid, cssRule); } } catch (error) { console.error('Error when parse descr_typo config', error); } } t_store_parseTypoStylesConfig( recid, '.t-product__option-selected-title', typoWithoutShadowJSON, 'js-store-options-selected-title-typo-styles-' + recid ); t_store_parseTypoStylesConfig( recid, '.t-product__option-title_select', typoWithoutShadowJSON, 'js-store-options-title-select-typo-styles-' + recid ); t_store_parseTypoStylesConfig( recid, '.t-product__option-select', typoWithoutShadowJSON, 'js-store-options-select-typo-styles-' + recid ); t_store_parseTypoStylesConfig( recid, '.t-product__option-title_radio', typoWithoutShadowJSON, 'js-store-options-title-radio-typo-styles-' + recid ); t_store_parseTypoStylesConfig( recid, '.t-product__option-title_buttons', typoWithoutShadowJSON, 'js-store-options-title-buttons-typo-styles-' + recid );}function t_store_option_getStyleInSnippet(descrColor, optionsColor) { var styleStr; var color = ''; if (descrColor && !optionsColor) { color = descrColor; } else if (optionsColor) { color = optionsColor; } var isGradient = color.startsWith('linear-gradient') || color.startsWith('radial-gradient'); if (!isGradient) { styleStr = color !== '' ? 'color:' + color + ';' : ''; } else if (isGradient) { styleStr = color !== '' ? 'color: transparent; background-clip: text; background-image:' + color + ';' : ''; } return styleStr;}/** * Устанавливает стили для характеристик товара в сниппете * @param {HTMLElement} snippetContainer - Контейнер сниппета товара