How do i set my radio button custom option to a default value? Now nothing is selected by default.
I suspect I can add or change something in -->
Mage/Catalog/Block/Product/View/Options/Type/Select.php
?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.
Sign up to join this communityHow do i set my radio button custom option to a default value? Now nothing is selected by default.
I suspect I can add or change something in -->
Mage/Catalog/Block/Product/View/Options/Type/Select.php
?
Yes you are correct, the custom options are rendered from the file app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php
To set a set a radio button custom option to a default value, write this code
if($_value->getTitle() == 'Title_of_your_custom_option')
{
$checked = 'checked';
}
before the below code
$selectHtml .= '<li>' . '<input type="' . $type . '" class="' . $class . ' ' . $require
. ' product-custom-option"'
. ($this->getSkipJsReloadPrice() ? '' : ' onclick="opConfig.reloadPrice()"')
. ' name="options[' . $_option->getId() . ']' . $arraySign . '" id="options_' . $_option->getId()
. '_' . $count . '" value="' . $htmlValue . '" ' . $checked . ' price="'
. $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false) . '" />'
. '<span class="label"><label for="options_' . $_option->getId() . '_' . $count . '">'
. $_value->getTitle() . ' ' . $priceStr . '</label></span>';
$selectHtml
to add the code
Jul 8, 2015 at 12:11
If you have a place to put some JavaScript, you could also check the first radio button in all of these option lists:
$('.options-list').find('input[type=radio]').first().prop('checked','checked');