Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Advanced Customer Search in Admin


dubz99

Recommended Posts

I am hoping to add the ability to search by customer id in /admin/customers.php.

 

I have found the default search in the code which is below.

 

<?php echo tep_draw_form('search', FILENAME_CUSTOMERS, '', 'get'); ?>
		<td class="pageHeading"><?php echo HEADING_TITLE; ?></td>
		<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', 1, HEADING_IMAGE_HEIGHT); ?></td>
		<td class="smallText" align="right"><?php echo HEADING_TITLE_SEARCH . ' ' . tep_draw_input_field('search'); ?></td>
		<?php echo tep_draw_form('search', FILENAME_CUSTOMERS, '', 'get'); ?>

 

I was hoping to either add another box to search by Customer ID or just have the main box search do it.

 

Any help would be appreciated.

 

BTW I also added a column to the customers.php and orders.php to make the customer id viewable on the page with success which appears at the far left.

 

TIA

dubz

Link to comment
Share on other sites

In customers.php

 

replace:

$search = "where c.customers_lastname like '%" . $keywords . "%' or c.customers_firstname like '%" . $keywords . "%' or c.customers_email_address like '%" . $keywords . "%'";

 

by:

$search = "where c.customers_id = '" . $keywords . "' or c.customers_lastname like '%" . $keywords . "%' or c.customers_firstname like '%" . $keywords . "%' or c.customers_email_address like '%" . $keywords . "%'";

Link to comment
Share on other sites

Perfect!

 

Many Thanks

 

dubz

 

 

In customers.php

 

replace:

$search = "where c.customers_lastname like '%" . $keywords . "%' or c.customers_firstname like '%" . $keywords . "%' or c.customers_email_address like '%" . $keywords . "%'";

 

by:

$search = "where c.customers_id = '" . $keywords . "' or c.customers_lastname like '%" . $keywords . "%' or c.customers_firstname like '%" . $keywords . "%' or c.customers_email_address like '%" . $keywords . "%'";

Link to comment
Share on other sites

oschellas

 

Is there anyway to do this from the store search? I found the code in advanced_search_result.php (below) but I do not know how to add the correct variable.

 

I would like to be able to do an exact search for inventory_number in the products table.

 

TIA

dubz

$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) . "%'";
	  $where_str .= " or pd.products_description like '%" . tep_db_input($keyword) . "%'";
	  $where_str .= " or pd.products_short_description like '%" . tep_db_input($keyword) . "%'";
	  $where_str .= " or pd.products_features like '%" . tep_db_input($keyword) . "%'";

Link to comment
Share on other sites

OK well I figured it out in the below code you just need to add the table "p." for products then the specific string you are looking for in my case the "stock_id", which would look like this "p.stock_id" then add the rest and you're good to go.

 

So my final code looks like the below, I also removed the "p.products_model" as it was make the query time unbearable (which is optional).

 

Original Code:

 

$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) . "%'";

 

Final Code with changes:

 

$where_str .= "(pd.products_name like '%" . tep_db_input($keyword) . "%' or p.stock_id like '%" . tep_db_input($keyword) . "%' or p.products_model like '%" . tep_db_input($keyword) . "%'";

 

Hope this helps any others looking to improve there search results!

 

dubz

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...