سؤال

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