문제

I need to pre-select certain custom options on a Simple product. They will be either drop downs or checkboxes.

도움이 되었습니까?

해결책

So for a custom option of type select, so drop down and checkboxes, the html for the values is generated at Mage_Catalog_Block_Product_View_Options_Type_Select::getValuesHtml().

What I would suggest to display the option defaults on the front end would be to rewrite this block and customize it to set the default options as selected.

For the checkboxes and radio have a look at the section:

$htmlValue = $_value->getOptionTypeId();
if ($arraySign) {
    $checked = (is_array($configValue) && in_array($htmlValue, $configValue)) ? 'checked' : '';
} else {
    $checked = $configValue == $htmlValue ? 'checked' : '';
}

And for selects and mutli-selects have a look at the section:

if ($configValue) {
    $select->setValue($configValue);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top