Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

icecold

Pioneers
  • Posts

    13
  • Joined

  • Last visited

1 Follower

Profile Information

  • Real Name
    R

icecold's Achievements

  1. I am working on that, unfortunately the dropdowns are a nightmare! There isn't a specific function to get the values to do the MySQL query!
  2. I modified the form in order to allow more extra fields as Select, but I can't find a way to modify it in order to allow my extra fields Selects to be selected as like %Option from select% >>> example Hair---> Blond, ..., so the query will read Select ... like %blond% select distinct p.products_image, p.products_weight, m.manufacturers_name, m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (products p left join products_to_products_extra_fields p2pef on p.products_id=p2pef.products_id) left join manufacturers m ON p.manufacturers_id = m.manufacturers_id left join specials s on p.products_id = s.products_id, products_description pd, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '3' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p.products_date_added >= '20000320' and p.products_date_added <= '20080907' order by pd.products_name This second query is the result of writing in the input field, and I need to fix the above query in order to display tep_db_input($keyword) from the select, BTW is there something like tep_db_select($option) function, somewhere, or similar? select distinct p.products_image, p.products_weight, m.manufacturers_name, m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price, IF(s.status, s.specials_new_products_price, p.products_price) as final_price from (products p left join products_to_products_extra_fields p2pef on p.products_id=p2pef.products_id) left join manufacturers m ON p.manufacturers_id = m.manufacturers_id left join specials s on p.products_id = s.products_id, products_description pd, categories c, products_to_categories p2c where p.products_status = '1' and p.products_id = pd.products_id and pd.language_id = '3' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and ((pd.products_name like '%rubia%' or p.products_model like '%rubia%' or m.manufacturers_name like '%rubia%' or p2pef.products_extra_fields_value like '%rubia%' or pd.products_description like '%rubia%') ) order by pd.products_name
  3. ok This is the query >>> $select_str = "select distinct " . $select_column_list . " m.manufacturers_id, p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, NULL as specials_new_products_price, NULL as final_price "; $from_str = "from (" . TABLE_PRODUCTS . " p left join " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " p2pef on p.products_id=p2pef.products_id) left join " . TABLE_MANUFACTURERS . " m on m.manufacturers_id=p.manufacturers_id, " . TABLE_PRODUCTS_DESCRIPTION . " pd left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c"; $where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%'or m.manufacturers_name like '%" . tep_db_input($keyword) . "%' or p2pef.products_extra_fields_value like '%" . tep_db_input($keyword) . "%'"; and $select_column_list (this code is before the SQL query)>>> // create column list $define_list = array('PRODUCT_LIST_MODEL' => PRODUCT_LIST_MODEL, 'PRODUCT_LIST_NAME' => PRODUCT_LIST_NAME, 'PRODUCT_LIST_MANUFACTURER' => PRODUCT_LIST_MANUFACTURER, 'PRODUCT_LIST_HAIR' => PRODUCT_LIST_HAIR, 'PRODUCT_LIST_EYES' => PRODUCT_LIST_EYES, 'PRODUCT_LIST_PRICE' => PRODUCT_LIST_PRICE, 'PRODUCT_LIST_QUANTITY' => PRODUCT_LIST_QUANTITY, 'PRODUCT_LIST_WEIGHT' => PRODUCT_LIST_WEIGHT, 'PRODUCT_LIST_IMAGE' => PRODUCT_LIST_IMAGE, 'PRODUCT_LIST_BUY_NOW' => PRODUCT_LIST_BUY_NOW); asort($define_list); $column_list = array(); reset($define_list); while (list($key, $value) = each($define_list)) { if ($value > 0) $column_list[] = $key; } // BOF Separate Pricing Per Customer if(!tep_session_is_registered('sppc_customer_group_id')) { $customer_group_id = '0'; } else { $customer_group_id = $sppc_customer_group_id; } // EOF Separate Pricing Per Customer $select_column_list = ''; for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { switch ($column_list[$i]) { case 'PRODUCT_LIST_MODEL': $select_column_list .= 'p.products_model, '; break; case 'PRODUCT_LIST_MANUFACTURER': $select_column_list .= 'm.manufacturers_name, '; break; case 'PRODUCT_LIST_HAIR': $select_column_list .= 'ph.hair, '; break; case 'PRODUCT_LIST_EYES': $select_column_list .= 'pe.eyes, '; break; case 'PRODUCT_LIST_QUANTITY': $select_column_list .= 'p.products_quantity, '; break; case 'PRODUCT_LIST_IMAGE': $select_column_list .= 'p.products_image, '; break; case 'PRODUCT_LIST_WEIGHT': $select_column_list .= 'p.products_weight, '; break; } }
  4. Thanks for replying so fast. ok those lines are the ones I created by modifying the original tep_manufacturers, function which lists manufacturers, my problem is my query works, as it shows blond and brunette, as a pull down, but when I submit the form, ok here goes the complete form >>> <?php echo tep_draw_form('advanced_search', tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, '', 'NONSSL', false), 'get', 'onSubmit="return check_form(this);"') . tep_hide_session_id(); ?><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td class="pageHeading"><?php echo HEADING_TITLE_1; ?></td> <td class="pageHeading" align="right"><?php /*echo tep_image(DIR_WS_IMAGES . 'table_background_browse.gif', HEADING_TITLE_1, HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); */?></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php if ($messageStack->size('search') > 0) { ?> <tr> <td><?php echo $messageStack->output('search'); ?></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <?php } ?> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="0"> <tr> <td height="14" class="infoBoxHeading"><img src="images/infobox/corner_left.gif" border="0" alt="" width="11" height="14"></td> <td width="100%" height="14" class="infoBoxHeading"><?php echo HEADING_SEARCH_CRITERIA; ?></td> <td height="14" class="infoBoxHeading" nowrap><img src="images/infobox/corner_right.gif" border="0" alt="" width="11" height="14"></td> </tr> </table> <table border="0" width="100%" cellspacing="0" cellpadding="1" class="infoBox"> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="3" class="infoBoxContents"> <tr> <td><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="1"></td> </tr> <tr> <td class="boxText"><?php echo tep_draw_input_field('keywords', '', 'style="width: 100%"'); ?></td> </tr> <tr> <td align="right" class="boxText"><?php echo tep_draw_hidden_field('search_in_description',1); /*tep_draw_checkbox_field('search_in_description', '1') . ' ' . TEXT_SEARCH_IN_DESCRIPTION;*/ ?></td> </tr> <tr> <td><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="1"></td> </tr> </table></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="smallText"><?php echo '<a href="java script:popupWindow(\'' . tep_href_link(FILENAME_POPUP_SEARCH_HELP) . '\')">' . TEXT_SEARCH_HELP_LINK . '</a>'; ?></td> <td class="smallText" align="right"><?php //echo tep_image_submit('button_search.gif', IMAGE_BUTTON_SEARCH); ?><img src="images/mod_button_left.gif" alt="" border="0"> <input style="padding-top: 2px; padding-bottom: 4px;" class="mod_button_submit" value="Buscar" type="submit" /> <img src="images/mod_button_right.gif" alt="" border="0"></td> </tr> </table></td> </tr> <tr> <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td><table border="0" width="100%" cellspacing="1" cellpadding="2" class="infoBox"> <tr class="infoBoxContents"> <td><table border="0" width="100%" cellspacing="0" cellpadding="2"> <tr> <td class="fieldKey"><?php echo ENTRY_CATEGORIES; ?></td> <td class="fieldValue"><?php echo tep_draw_pull_down_menu('categories_id', tep_get_categories(array(array('id' => '', 'text' => TEXT_ALL_CATEGORIES)))); ?></td> </tr> <tr> <td class="fieldKey"> </td> <td class="smallText"><?php echo tep_draw_checkbox_field('inc_subcat', '1', true) . ' ' . ENTRY_INCLUDE_SUBCATEGORIES; ?></td> </tr> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td class="fieldKey"><?php echo ENTRY_MANUFACTURERS; ?></td> <td class="fieldValue"><?php echo tep_draw_pull_down_menu('manufacturers_id', tep_get_manufacturers(array(array('id' => '', 'text' => TEXT_ALL_MANUFACTURERS)))); ?></td> </tr> <tr> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <!--New extra fields Inserted here in query--> <tr> <td class="fieldKey"><?php echo ENTRY_HAIR; ?></td>// <td class="fieldValue"><?php echo tep_draw_pull_down_menu('products_to_products_extra_fields_id', tep_get_extra(array(array('id' => '', 'text' => TEXT_ALL_HAIR)))); ?></td> </tr> <tr> <td class="fieldKey"><?php echo ENTRY_EYES; ?></td> <td class="fieldValue"><?php echo tep_draw_pull_down_menu('products_to_products_extra_fields_id', tep_get_extra1(array(array('id' => '', 'text' => TEXT_ALL_EYES)))); ?></td> </tr> <tr> <!--End new fields--> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <!-- Other modifications in other to compare Age and Height entries and check if value FROM is not bigger than value TO etc All necessary modifications were made to the javascript code based on the way it compares prices and dates --> <td class="fieldKey"><?php echo ENTRY_AGE_FROM; ?></td> <td class="fieldValue"><?php echo tep_draw_input_field('afrom'); ?></td> </tr> <tr> <td class="fieldKey"><?php echo ENTRY_AGE_TO; ?></td> <td class="fieldValue"><?php echo tep_draw_input_field('ato'); ?></td> </tr> <tr> <td class="fieldKey"><?php echo ENTRY_HEIGHT_FROM; ?></td> <td class="fieldValue"><?php echo tep_draw_input_field('hfrom'); ?></td> </tr> <tr> <td class="fieldKey"><?php echo ENTRY_HEIGHT_TO; ?></td> <td class="fieldValue"><?php echo tep_draw_input_field('hto'); ?></td> </tr> <!-- Old code for Price commented out as irrelevant /* <tr> <td class="fieldKey"><?php//echo ENTRY_PRICE_FROM; ?></td> <td class="fieldValue"><?php//echo tep_draw_input_field('pfrom'); ?></td> </tr> <tr> <td class="fieldKey"><?php// echo ENTRY_PRICE_TO; ?></td> <td class="fieldValue"><?php// echo tep_draw_input_field('pto'); ?></td> </tr> <tr>*/--> <td colspan="2"><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td> </tr> <tr> <td class="fieldKey"><?php echo ENTRY_DATE_FROM; ?></td> <td class="fieldValue"><?php echo tep_draw_input_field('dfrom', DOB_FORMAT_STRING, 'onFocus="RemoveFormatString(this, \'' . DOB_FORMAT_STRING . '\')"'); ?></td> </tr> <tr> <td class="fieldKey"><?php echo ENTRY_DATE_TO; ?></td> <td class="fieldValue"><?php echo tep_draw_input_field('dto', DOB_FORMAT_STRING, 'onFocus="RemoveFormatString(this, \'' . DOB_FORMAT_STRING . '\')"'); ?></td> </tr> </table></td> </tr> </table></td> </tr> </table></form> Next I modified Advanced Search results, I commented all my mods. require('includes/application_top.php'); require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_ADVANCED_SEARCH); $error = false; if ( (isset($HTTP_GET_VARS['keywords']) && empty($HTTP_GET_VARS['keywords'])) && (isset($HTTP_GET_VARS['dfrom']) && (empty($HTTP_GET_VARS['dfrom']) || ($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING))) && (isset($HTTP_GET_VARS['dto']) && (empty($HTTP_GET_VARS['dto']) || ($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING))) && // $afrom, $hfrom, $ato and $hto added to the code (isset($HTTP_GET_VARS['afrom']) && !is_numeric($HTTP_GET_VARS['afrom'])) && (isset($HTTP_GET_VARS['ato']) && !is_numeric($HTTP_GET_VARS['ato'])) && (isset($HTTP_GET_VARS['hfrom']) && !is_numeric($HTTP_GET_VARS['hfrom'])) && (isset($HTTP_GET_VARS['hto']) && !is_numeric($HTTP_GET_VARS['hto'])) && //end additions (isset($HTTP_GET_VARS['pfrom']) && !is_numeric($HTTP_GET_VARS['pfrom'])) && (isset($HTTP_GET_VARS['pto']) && !is_numeric($HTTP_GET_VARS['pto'])) ) { $error = true; $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT); } else { $dfrom = ''; $dto = ''; //$afrom, $hfrom, $ato and $hto $afrom = ''; $ato = ''; $hfrom = ''; $hto = ''; //end additional vars $pfrom = ''; $pto = ''; $keywords = ''; if (isset($HTTP_GET_VARS['dfrom'])) { $dfrom = (($HTTP_GET_VARS['dfrom'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dfrom']); } if (isset($HTTP_GET_VARS['dto'])) { $dto = (($HTTP_GET_VARS['dto'] == DOB_FORMAT_STRING) ? '' : $HTTP_GET_VARS['dto']); } /* code Added for checking Age and Height*/ if (isset($HTTP_GET_VARS['afrom'])) { $pfrom = $HTTP_GET_VARS['afrom']; } if (isset($HTTP_GET_VARS['ato'])) { $pto = $HTTP_GET_VARS['ato']; } if (isset($HTTP_GET_VARS['hfrom'])) { $pfrom = $HTTP_GET_VARS['hfrom']; } if (isset($HTTP_GET_VARS['hto'])) { $pto = $HTTP_GET_VARS['hto']; } /* End additions*/ if (isset($HTTP_GET_VARS['pfrom'])) { $pfrom = $HTTP_GET_VARS['pfrom']; } if (isset($HTTP_GET_VARS['pto'])) { $pto = $HTTP_GET_VARS['pto']; } if (isset($HTTP_GET_VARS['keywords'])) { $keywords = $HTTP_GET_VARS['keywords']; } $date_check_error = false; if (tep_not_null($dfrom)) { if (!tep_checkdate($dfrom, DOB_FORMAT_STRING, $dfrom_array)) { $error = true; $date_check_error = true; $messageStack->add_session('search', ERROR_INVALID_FROM_DATE); } } if (tep_not_null($dto)) { if (!tep_checkdate($dto, DOB_FORMAT_STRING, $dto_array)) { $error = true; $date_check_error = true; $messageStack->add_session('search', ERROR_INVALID_TO_DATE); } } if (($date_check_error == false) && tep_not_null($dfrom) && tep_not_null($dto)) { if (mktime(0, 0, 0, $dfrom_array[1], $dfrom_array[2], $dfrom_array[0]) > mktime(0, 0, 0, $dto_array[1], $dto_array[2], $dto_array[0])) { $error = true; $messageStack->add_session('search', ERROR_TO_DATE_LESS_THAN_FROM_DATE); } } //Age Start Checks input and makes sure non numeric values are entered else returns an error $age_check_error = false; if (tep_not_null($afrom)) { if (!settype($afrom, 'double')) { $error = true; $age_check_error = true; $messageStack->add_session('search', ERROR_AGE_FROM_MUST_BE_NUM); } } $height_check_error = false; if (tep_not_null($ato)) { if (!settype($afrom, 'double')) { $error = true; $age_check_error = true; $messageStack->add_session('search', ERROR_AGE_TO_MUST_BE_NUM); } } //Age End //Height Starts using the same parameters as Age $height_check_error = false; if (tep_not_null($hfrom)) { if (!settype($hfrom, 'double')) { $error = true; $height_check_error = true; $messageStack->add_session('search', ERROR_HEIGHT_FROM_MUST_BE_NUM); } } if (tep_not_null($hto)) { if (!settype($hto, 'double')) { $error = true; $height_check_error = true; $messageStack->add_session('search', ERROR_HEIGHT_TO_MUST_BE_NUM); } } // Height Ends $price_check_error = false; if (tep_not_null($pfrom)) { if (!settype($pfrom, 'double')) { $error = true; $price_check_error = true; $messageStack->add_session('search', ERROR_PRICE_FROM_MUST_BE_NUM); } } if (tep_not_null($pto)) { if (!settype($pto, 'double')) { $error = true; $price_check_error = true; $messageStack->add_session('search', ERROR_PRICE_TO_MUST_BE_NUM); } } //aGE AND HEIGHT CHECK if they are floting numbers and Age/Height TO is not bigger than FROM if (($age_check_error == false) && is_float($afrom) && is_float($ato)) { if ($afrom >= $ato) { $error = true; $messageStack->add_session('search', ERROR_AGE_TO_LESS_THAN_AGE_FROM); } } if (($height_check_error == false) && is_float($hfrom) && is_float($hto)) { if ($hfrom >= $hto) { $error = true; $messageStack->add_session('search', ERROR_HEIGHT_TO_LESS_THAN_HEIGHT_FROM); } } //END if (($price_check_error == false) && is_float($pfrom) && is_float($pto)) { if ($pfrom >= $pto) { $error = true; $messageStack->add_session('search', ERROR_PRICE_TO_LESS_THAN_PRICE_FROM); } } if (tep_not_null($keywords)) { if (!tep_parse_search_string($keywords, $search_keywords)) { $error = true; $messageStack->add_session('search', ERROR_INVALID_KEYWORDS); } } } //I commented out $ato and $hto because the script returned an error ... if (empty($dfrom) && empty($dto) //&& empty($afrom) && empty($ato)&& empty($hfrom) && empty(hto) && empty($pfrom) && empty($pto) && empty($keywords)) { $error = true; $messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT); } if ($error == true) { tep_redirect(tep_href_link(FILENAME_ADVANCED_SEARCH, tep_get_all_get_params(), 'NONSSL', true, false)); } $breadcrumb->add(NAVBAR_TITLE_1, tep_href_link(FILENAME_ADVANCED_SEARCH)); $breadcrumb->add(NAVBAR_TITLE_2, tep_href_link(FILENAME_ADVANCED_SEARCH_RESULT, tep_get_all_get_params(), 'NONSSL', true, false)); $content = CONTENT_ADVANCED_SEARCH_RESULT; include (bts_select('main', $content_template)); // BTSv1.5 require(DIR_WS_INCLUDES . 'application_bottom.php'); ?> After checking and rechecking all my code I am not able to find out why the function draw form is not passing the values selected in the pulldown function, so please let me know your insight and thanks again for your help.
  5. Hi, I managed to install Product Extra Fields contribution, and I need to modify Advanced search in order to display a pull down of each of the new fields. For instance I have: Hair: > Blond, Brunette, Black etc and that is working as a pulldown, but so far I wasn't able to modify the script in order to get the values from the pulldown. In order to create a pulldown I added this function to includes/functions/general.php: //Function get EXtra fields function tep_get_extra($extra_array = '') { if (!is_array($extra_array)) $extra_array = array(); $extra_query = tep_db_query("select products_extra_fields_value from " . TABLE_PRODUCTS_TO_PRODUCTS_EXTRA_FIELDS . " where products_extra_fields_id = '1'"); while ($extra = tep_db_fetch_array($extra_query)) { $extra_array[] = array('id' => $extra['products_extra_fields_id'], 'text' => $extra['products_extra_fields_value']); } return $extra_array; } // End 1 is the ID of the field I am displaying (Hair) and it works fine as it displays Hair >> and the values are Blond, Brunette, etc As i said my first problem is even it shows the options and they are fieldKeys, the form is not processing them here is my code in /templates/myt/content/advanced_search.tpl.php <td class="fieldKey"><?php echo ENTRY_HAIR; ?></td> <td class="fieldValue"><?php echo tep_draw_pull_down_menu('products_to_products_extr a_fields_id', tep_get_extra(array(array('id' => '', 'text' => TEXT_ALL_HAIR)))); ?></td> </tr> And If I just select from the pull down I got this error >>> my second problem is to create a for loop that checks for extra fields ids, as now what I done so far is to simply create another function for each of the extra fields ... 'Error At least one of the fields in the search form must be entered.' This happens even when one of the options is selected ... Any suggestions are welcome
×
×
  • Create New...