简体   繁体   中英

Magento Custom Options - add a CSS className to the custom option in dropdown

I want to specify a CSS class to apply to my custom options. This will allow me to use more robust JavaScript selectors on the product view page.

I have tried a lot but not getting how to add.

在此处输入图片说明

For this i am trying to change in Mage\\Catalog\\Block\\Product\\View\\Options\\Type\\select.php

and following line is adding this options

$select->addOption(
                    $_value->getOptionTypeId(),
                    $_value->getTitle() . ' ' . $priceStr . '',
                    array('price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false)),
                    array('class' => 'testsfs')
                );

But not getting how i can add my custom class to this option. I hope someone help me.

Thanks.

Finally found the solution. Only need to add 'class' => 'myClass' in array.

$select->addOption(
                    $_value->getOptionTypeId(),
                    $_value->getTitle() . ' ' . $priceStr . '',
                    array('price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false), 'class' => 'myClass')
                );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM