When i inspect Custom option values which are displaying in product view page , i got below code is reason to display those values.
code :
<span id="options-<?php echo $_option->getId() ?>-container"></span>
inspect element :
here, is there any chance we can display different color for different custom option values, for example, Black => Black, Green => Green .
can we use different css classes or ids for each value ?
<dd<?php if ($_option->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<?php echo $this->getValuesHtml() ?>
<?php if ($_option->getIsRequire()): ?>
<?php if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX): ?>
<span id="options-<?php echo $_option->getId() ?>-container"></span>
<?php endif; ?>
<?php endif;?>
</div>
</dd>
1 Answer 1
there is not straight way to do it you can do it by javascript
This solution for dropdown
var x = document.getElementById("mySelect"); //select id here
var i;
for (i = 0; i < x.length; i++) {
tex=x.options[i].text; // option text
var tex = tex.toLowerCase(); //make it lower
x.options[i].style.backgroundColor = tex; // set the background color for that
}
you can use css
label[for=options_455_2]
{
/* ...add css here... */
}
-
i tried like this , seems i am doing something wrong, please check this :
var x = document.getElementById("options_455_2"); //select id here var i; for (i = 0; i < x.length; i++) { tex=Black.options[i].text; // option text var tex = tex.toLowerCase(); //make it lower x.options[i].style.backgroundColor = red; // set the background color for that }Baby in Magento– Baby in Magento2017年01月19日 10:42:25 +00:00Commented Jan 19, 2017 at 10:42 -
if you check link & update the answer as per my requirement, that will be really helpfull..... , "custom option value" =
black.....Baby in Magento– Baby in Magento2017年01月19日 10:48:01 +00:00Commented Jan 19, 2017 at 10:48 -
@BabyinMagento added the simple solution for youQaisar Satti– Qaisar Satti2017年01月19日 11:03:00 +00:00Commented Jan 19, 2017 at 11:03
-
yes, now i can apply different css for different custom values, give me 10 min, i have one more doubt.....Baby in Magento– Baby in Magento2017年01月19日 11:10:33 +00:00Commented Jan 19, 2017 at 11:10
simple product with custom options, i am not usingconfigurable product, can you please tell what is the css class for code i posted in question , is it_455_2?Black & Greenfor all products, i tried adding internal css as.options_453_3 { color : red; } .options_453_2 { color : red; }, but it did't displayed in "red" color..... is the way i am doing is right ?