Zen Cart Logo
Forums / Code Collaboration / Extra Search fields in custom Search form

Extra Search fields in custom Search form

Views: 3,201

Results 1 to 3 of 3
13 Mar 2013, 3:23 PM
#1
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Extra Search fields in custom Search form

Heyas,
Well, I went and done it again :shocking:
I created a 2nd Advanced search form with it's own results page. Some how, I was able to make it work great :clap: with the exception of 1 small thing lol, when i first created it a few weeks ago, it only had 3 fields, all of which are in an additional fields table that works well and and the customer is pleased as punch with it. Then it was decided that 3 more fields needed to be added. So I went in and added the 3 extra fields, 1 of them is "price" which comes from the product table and 2 that come from the additional fields table.

http://surferweb.com/ojlparts/index.php?main_page=advanced_forklift_search

Now if you select any or all of these 3, Capacity, Fuel, Tires, it's works as expected and I get the proper results.
However, Selecting ANY of the other 3, Price, Make, or Mast Type it all goes haywire :frusty:
I have enabled some variables on the bottom of the page to see whats happening, particularly the "WHERE" clause, no matter which one is selected it set s the fuel box to whatever index you select.
Now for some code:
includes/modules/pages/advanced_forklift_search_result/header_php.php

$_GET['tires'] = trim($_GET['tires']);
$_GET['fuel'] = trim($_GET['fuel']);
$_GET['make'] = trim($_GET['make']);
$_GET['mast'] = trim($_GET['mast']);
$_GET['price'] = trim($_GET['price']);

 if( $_GET['capacity']==0 && $_GET['tires']==0 && $_GET['fuel']==0 && ($_GET['make'] == 0) && ($_GET['mast'] == 0) && ($_GET['price'] == 0) ){
	$error = true;
	$missing_one_input = true;
	$messageStack->add_session('search', ERROR_AT_LEAST_ONE_INPUT);
  } else {
	$tires = '';
	$fuel = '';
	$capacity = '';
	$make = '';
	$mast = '';
	$price = '';
  
	  if ($_GET['capacity']!= 0 ) {
		  $capacity = $_GET['capacity'];
	  }
	 if ($_GET['tires']!= 0 ) {
		  $tires = $_GET['tires'];
	  }
	 if ($_GET['fuel']!= 0 ) {
		  $fuel = $_GET['fuel'];
	  }
	  if ($_GET['make']!= 0 ) {
		  $fuel = $_GET['make'];
	  }
	  if ($_GET['mast']!= 0 ) {
		  $fuel = $_GET['mast'];
	  }
	  if ($_GET['price']!= 0 ) {
		  $fuel = $_GET['price'];
	  }
  }

This is where I think the problem is, I don't think the 3 new fields are defined anywhere and for the life of me I don't remember where I defined the 3 other fields, I know they weren't standard because they are in an additional fields table.

switch ($column_list[$col]) {
    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_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;
	case 'PRODUCT_LIST_PRICE':
    $select_column_list .= 'p.products_price';
    break;
	case 'FORKLIFT_CPAC':
    $select_column_list .= 'pf.forklift_cpac';
    break;
	case 'FORKLIFT_TIRES':
    $select_column_list .= 'pf.forklift_tires';
    break;
	case 'FORKLIFT_FUEL':
    $select_column_list .= 'pf.forklift_fuel';
    break;
	case 'FORKLIFT_MAKE':
    $select_column_list .= 'pf.forklift_make';
    break;
	case 'FORKLIFT_MAST_TYPE':
    $select_column_list .= 'pf.forklift_mast_type';
    break;
	
  }

here is the where statement:

if ($capacity != 0){
			$where_str .= " AND ";
			
			$where_str .= "((pf.forklift_cpac >= '$lh') and (pf.forklift_cpac <= '$hh'))";
		}
		if ($fuel != 0){
			$where_str .= " AND ";
			
			$where_str .= "pf.forklift_fuel='$fuel_type'";
		}
		if ($tires != 0){
			$where_str .= " AND ";
			
			$where_str .= "pf.forklift_tires='$tire_type'";
		}
		if ($make != 0){
			$where_str .= " AND ";
			
			$where_str .= "pf.forklift_make='$make_f'";
		}
		if ($mast != 0){
			$where_str .= " AND ";
			
			$where_str .= "pf.forklift_mast='$mast_type'";
		}
		if ($price != 0){
			$where_str .= " AND ";
			if ($price < 4){
				$where_str .= "((p.products_price >= '$pr_l') and (p.products_price <= '$pr_h'))";
			} else {
				$where_str .= "p.products_price >= '$pr_l'";
			}
		}

I have checked everywhere for the defines and cant seem to figure out where these need to be.
Any direction would be appreciated.

Thanks in Advance
Jeff

13 Mar 2013, 9:52 PM
#2
lankeeyankee avatar

lankeeyankee

Totally Zenned

Join Date:
Jan 2007
Posts:
1,514
Plugin Contributions:
1

Re: Extra Search fields in custom Search form

In the admin section, tools>developers toolkit. Will quickly become your best friend. Search for your define and it will tell you which file it's in. IMO, this is one of the most powerful features of zen cart with regards to customizations of php and css files.

14 Mar 2013, 12:19 AM
#3
jeffiec avatar

jeffiec

New Zenner

Join Date:
Jun 2009
Posts:
86
Plugin Contributions:
0

Re: Extra Search fields in custom Search form

tools>developers toolkit = GOD! I know, I've searched it and i don't see the define for FORKLIFT_CPAC which is one of the ones that works, so I figured if i could find the define for it, I could find where to define the missing ones, but to no avail.
But the price define is a system define, it should work shouldnt it?
It's like somehow defined as only 3 fields, not 6?