Magento 1.9 – Fix ‘Selected Options Not Available’ Error

magento-1.9

I create one configurable product and create 5 Associative products for that configurable product and I create two custom options for one product. After,give values to options and I add that product to shopping cart and I got the following Error in cart page

Error Message

I have used following code to get custom options:

 if($option->getDefaultTitle()== "Measurement" && $input_type =="drop_down")      {
 echo '<div class="input-box">';
 echo '<select id="drop" name="options['.$option->getId().']"   title="" ><option value="">select</option><option value="2" price="0">Feet </option><option value="1" price="0">Mtr </option></select>';
       echo '<input class="validate-one-required-by-name" type="'.$input_type.'" name="options['.$option->getId().']" value=""/>';
       echo '</div>';
}

Best Answer

Please use the following code to get the options of select dropdown

if($option->getDefaultTitle()== "Measurement" && $input_type == "drop_down")     {               
echo "<select id='drop' style='display:block; clear:both;' name='options[".$option->getId()."]'>";
    foreach($option->getValues() as $valuesKey => $valuesVal)
        {
          echo  "<option value='".$valuesVal->getId()."'>".$valuesVal->getTitle()."</option>";
        }
                echo "</select>";
}