Public Member Functions | |
getValuesHtml () |
Definition at line 35 of file Select.php.
getValuesHtml | ( | ) |
Definition at line 39 of file Select.php.
00040 { 00041 $_option = $this->getOption(); 00042 00043 if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN 00044 || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) { 00045 $require = ($_option->getIsRequire()) ? ' required-entry' : ''; 00046 $extraParams = ''; 00047 $select = $this->getLayout()->createBlock('core/html_select') 00048 ->setData(array( 00049 'id' => 'select_'.$_option->getId(), 00050 'class' => $require.' product-custom-option' 00051 )); 00052 if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_DROP_DOWN) { 00053 $select->setName('options['.$_option->getid().']') 00054 ->addOption('', $this->__('-- Please Select --')); 00055 } else { 00056 $select->setName('options['.$_option->getid().'][]'); 00057 $select->setClass('multiselect'.$require.' product-custom-option'); 00058 } 00059 foreach ($_option->getValues() as $_value) { 00060 $priceStr = $this->_formatPrice(array( 00061 'is_percent' => ($_value->getPriceType() == 'percent') ? true : false, 00062 'pricing_value' => $_value->getPrice(true) 00063 ), false); 00064 $select->addOption( 00065 $_value->getOptionTypeId(), 00066 $_value->getTitle() . ' ' . $priceStr . '' 00067 ); 00068 } 00069 if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_MULTIPLE) { 00070 $extraParams = ' multiple="multiple"'; 00071 } 00072 $select->setExtraParams('onchange="opConfig.reloadPrice()"'.$extraParams); 00073 00074 return $select->getHtml(); 00075 } 00076 00077 if ($_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO 00078 || $_option->getType() == Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX 00079 ) { 00080 $selectHtml = '<ul id="options-'.$_option->getId().'-list" class="options-list">'; 00081 $require = ($_option->getIsRequire()) ? ' validate-one-required-by-name' : ''; 00082 $arraySign = ''; 00083 switch ($_option->getType()) { 00084 case Mage_Catalog_Model_Product_Option::OPTION_TYPE_RADIO: 00085 $type = 'radio'; 00086 $class = 'radio'; 00087 if (!$_option->getIsRequire()) { 00088 $selectHtml .= '<li><input type="radio" id="options_'.$_option->getId().'" class="'.$class.' product-custom-option" name="options['.$_option->getId().']" onclick="opConfig.reloadPrice()" value="" checked="checked" /><span class="label"><label for="options_'.$_option->getId().'">' . $this->__('None') . '</label></span></li>'; 00089 } 00090 break; 00091 case Mage_Catalog_Model_Product_Option::OPTION_TYPE_CHECKBOX: 00092 $type = 'checkbox'; 00093 $class = 'checkbox'; 00094 $arraySign = '[]'; 00095 break; 00096 } 00097 $count = 1; 00098 foreach ($_option->getValues() as $_value) { 00099 $count++; 00100 $priceStr = $this->_formatPrice(array( 00101 'is_percent' => ($_value->getPriceType() == 'percent') ? true : false, 00102 'pricing_value' => $_value->getPrice(true) 00103 )); 00104 $selectHtml .= '<li>' . 00105 '<input type="'.$type.'" class="'.$class.' '.$require.' product-custom-option" onclick="opConfig.reloadPrice()" name="options['.$_option->getId().']'.$arraySign.'" id="options_'.$_option->getId().'_'.$count.'" value="'.$_value->getOptionTypeId().'" />' . 00106 '<span class="label"><label for="options_'.$_option->getId().'_'.$count.'">'.$_value->getTitle().' '.$priceStr.'</label></span>'; 00107 if ($_option->getIsRequire()) { 00108 $selectHtml .= '<script type="text/javascript">' . 00109 '$(\'options_'.$_option->getId().'_'.$count.'\').advaiceContainer = \'options-'.$_option->getId().'-container\';' . 00110 '$(\'options_'.$_option->getId().'_'.$count.'\').callbackFunction = \'validateOptionsCallback\';' . 00111 '</script>'; 00112 } 00113 $selectHtml .= '</li>'; 00114 } 00115 $selectHtml .= '</ul>'; 00116 return $selectHtml; 00117 } 00118 }