rqualls Posted December 10, 2013 Posted December 10, 2013 I have options types v2 from zappo installed and trying to figure out how to get the images dropdown to contain a default -- Please Select -- option that has no value and does not get included in checkout and cart. Currently, I have entered the option in admin attributes for "Please Select Image" with no value, but this option value still shows up during checkout and is included with the order even though the user has not selected an option. I did place an extra $Image_Dropdown[$product_info['products_id']] .= '<option value="">Please Select</option>'; in the installed code for V2 and which almost did the trick, but the values within the dropdown were then out of sync. Anybody dealt with this before? Thanks, RQ Here is my code: -------------------------------------------------------------------------- //BOF - Zappo - Added Image Selector Option case OPTIONS_TYPE_IMAGE: $Image_Opticount_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id='" . (int)$product_info['products_id'] . "' and options_id ='" . (int)$ProdOpt_ID . "'"); $Image_Opticount = tep_db_fetch_array($Image_Opticount_query); $Image_displayed = 0; /* $Image_Dropdown[$product_info['products_id']] .= '<option value="">Please Select</option>'; */ $products_options_query = tep_db_query("select pov.products_options_values_id, pov.products_options_values_name, pa.options_values_price, pa.price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " pa, " . TABLE_PRODUCTS_OPTIONS_VALUES . " pov where pa.products_id = '" . (int)$product_info['products_id'] . "' and pa.options_id = '" . (int)$ProdOpt_ID . "' and pa.options_values_id = pov.products_options_values_id and pov.language_id = '" . (int)$languages_id . "' order by pa.products_options_sort_order"); while ($products_options = tep_db_fetch_array($products_options_query)) { $pOptValName = $products_options['products_options_values_name']; $Image_displayed++; if ($products_options['options_values_price'] != '0') { $option_price = ' (' . $products_options['price_prefix'] . ' ' . $currencies->display_price($products_options['options_values_price'], tep_get_tax_rate($product_info['products_tax_class_id'])) .') '; } else { $option_price = ''; } $Image_Dropdown_ID = 'id[' . $ProdOpt_ID . ']'; $Image_Name = (OPTIONS_TYPE_IMAGENAME == 'Name') ? $products_options['products_options_values_name'] : $products_options['products_options_values_id']; $Real_Image_Name = OPTIONS_TYPE_IMAGEPREFIX . $Image_Name . ((OPTIONS_TYPE_IMAGELANG == 'Yes') ? '_'.$languages_id : '') . '.jpg'; if (isset($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$ProdOpt_ID]) && ($cart->contents[$HTTP_GET_VARS['products_id']]['attributes'][$ProdOpt_ID] == $products_options['products_options_values_id'])) { $Image_Dropdown[$product_info['products_id']] .= '<option value="' . $products_options['products_options_values_id'] . '" SELECTED>' . $pOptValName . $option_price . '</option>'; $First_ImageText[$product_info['products_id']] = '<img src="' . OPTIONS_TYPE_IMAGEDIR . $Real_Image_Name . '" alt="'.$pOptValName.'" title="'.$pOptValName.'">'; $ImageText[$product_info['products_id']] .= '"<img src=\"' . OPTIONS_TYPE_IMAGEDIR . $Real_Image_Name . '\" alt=\"'.$pOptValName.'\" title=\"'.$pOptValName.'\">"'; } else { $Image_Dropdown[$product_info['products_id']] .= '<option value="' . $products_options['products_options_values_id'] . '">' . $pOptValName . $option_price . '</option>'; $ImageText[$product_info['products_id']] .= '"<img src=\"' . OPTIONS_TYPE_IMAGEDIR . $Real_Image_Name . '\" alt=\"'.$pOptValName.'\" title=\"'.$pOptValName.'\">"'; if ($First_ImageText[$product_info['products_id']] == '' && $Image_displayed == 1) $First_ImageText[$product_info['products_id']] = '<img src="' . OPTIONS_TYPE_IMAGEDIR . $Real_Image_Name . '" alt="'.$pOptValName.'" title="'.$pOptValName.'">'; } // BOF - Zappo - PreLoad the Images if ($Image_displayed == 1) echo '<div id="ImagePreload">'; echo '<img src="' . OPTIONS_TYPE_IMAGEDIR . $Real_Image_Name . '" alt="'.$pOptValName.'" title="'.$pOptValName.'" >'; if ($Image_displayed != $Image_Opticount['total']) { $ImageText[$product_info['products_id']] .= ','; } else { // - Zappo - PreLoad the Images - Close Div... echo '</div>'; } // EOF - Zappo - PreLoad the Images } $ImageSelector_Dropdown = '<select name="' . $Image_Dropdown_ID . '" onchange="document.getElementById(\'ImageSelect' . $product_info['products_id'] . '\').innerHTML=ImageText'.$product_info['products_id'].'[this.selectedIndex];">' . $Image_Dropdown[$product_info['products_id']] . '</select> ' ; $ImageSelector_Name = $ProdOpt_Name . ': <script language="Javascript" type="text/Javascript">var ImageText'.$product_info['products_id'] . ' = new Array(' . $ImageText[$product_info['products_id']] . ')</script>'; $ImageSelector_Comment = $ProdOpt_Comment . ': <script language="Javascript" type="text/Javascript">var ImageText'.$product_info['products_id'] . ' = new Array(' . $ImageText[$product_info['products_id']] . ')</script>'; ?> --------------------------------------------------------------------------
MrPhil Posted December 10, 2013 Posted December 10, 2013 This kind of thing is usually handled with a Javascript routine invoked on page submit. It would check that the value being returned by the select is not '' or "Please Select". If it is, it would put up an error message and stay on that page (rather than letting the form data be submitted to the server). It can also be done at the form data processing on the server -- if the select's returned data is invalid, you redraw the form page, usually with an error message added. This involves an extra round trip between the browser and the server, as well as requiring you to know exactly how the page is being put up in the first place, so you can properly redraw it without duplicating any actions.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.