Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Customers Drop Down In Orders List


niviche

Recommended Posts

This is the support thread for:

 

Customers Drop Down In Orders List

 

http://www.oscommerce.com/community/contributions,4818

 

This contribution adds a drop down menu in the orders list in the admin section. You can then choose to see only orders by a specific customer.

Customers are ordered alphabetically by last name.

 

customers_drop_down_in_orders_list.jpg

Edited by niviche
Link to comment
Share on other sites

I was getting error message with unknown table if someone is having the same problem just replace:

 

// customers drop down in orders list begins

} elseif (isset($HTTP_GET_VARS['customers_id']) && ($HTTP_GET_VARS['customers_id'] > 0)) {

$invoice_number = tep_db_prepare_input($HTTP_GET_VARS['customers_id']);

$status = tep_db_prepare_input($HTTP_GET_VARS['status']);

$orders_query_raw = "select o.orders_id, o.invoice_serial, o.invoice_number, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$customers_id . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by orders_id DESC";

// customers drop down in orders list ends

 

 

With :

 

 

// customers drop down in orders list begins

} elseif (isset($HTTP_GET_VARS['customers_id']) && ($HTTP_GET_VARS['customers_id'] > 0)) {

$invoice_number = tep_db_prepare_input($HTTP_GET_VARS['customers_id']);

$status = tep_db_prepare_input($HTTP_GET_VARS['status']);

$orders_query_raw = "select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$customers_id . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by orders_id DESC";

// customers drop down in orders list ends

 

 

Also if you want to display them with the last name than first replace:

 

 

<? // customers drop down in orders list begins

?>

<tr>

 

<?

$customers_query = tep_db_query("select customers_id, customers_firstname, customers_lastname from " . TABLE_CUSTOMERS . " order by customers_lastname");

while ($customers = tep_db_fetch_array($customers_query)) {

$customers_firstname = $customers['customers_firstname'];

$customers_lastname = $customers['customers_lastname'];

$customers_array[] = array('id' => $customers['customers_id'],

'text' => $customers_firstname . ' ' . $customers_lastname);

}

?>

<td class="smallText" align="right"><?php echo tep_draw_form('customers', FILENAME_ORDERS, '', 'get') . TABLE_HEADING_CUSTOMERS . ' ' . tep_draw_pull_down_menu('customers_id', array_merge(array(array('id' => '', 'text' => '')), $customers_array), (isset($HTTP_GET_VARS['customers_id']) ? $HTTP_GET_VARS['customers_id'] : ''), 'onChange="this.form.submit();"'); ?></form></td>

</tr>

<? // customers drop down in orders list ends

?>

 

With:

<? // customers drop down in orders list begins

?>

<tr>

 

<?

$customers_query = tep_db_query("select customers_id, customers_lastname, customers_firstname from " . TABLE_CUSTOMERS . " order by customers_lastname");

while ($customers = tep_db_fetch_array($customers_query)) {

$customers_lastname = $customers['customers_lastname'];

$customers_firstname = $customers['customers_firstname'];

$customers_array[] = array('id' => $customers['customers_id'],

'text' => $customers_lastname . ' ' . $customers_firstname);

}

?>

<td class="smallText" align="right"><?php echo tep_draw_form('customers', FILENAME_ORDERS, '', 'get') . TABLE_HEADING_CUSTOMERS . ' ' . tep_draw_pull_down_menu('customers_id', array_merge(array(array('id' => '', 'text' => '')), $customers_array), (isset($HTTP_GET_VARS['customers_id']) ? $HTTP_GET_VARS['customers_id'] : ''), 'onChange="this.form.submit();"'); ?></form></td>

</tr>

<? // customers drop down in orders list ends

 

Nice addition, all credit credit goes to niviche

Link to comment
Share on other sites

I was getting error message with unknown table if someone is having the same problem just replace:

 

You are right, there were artifacts in this query left from another contribution installed on my site.

 

I'm updating the contribution page with this.

Link to comment
Share on other sites

A3. find:

} elseif (isset($HTTP_GET_VARS['status']) && is_numeric($HTTP_GET_VARS['status']) && ($HTTP_GET_VARS['status'] > 0)) {

 

I checked the orders.php file 10 times and couldn't find a line that resemble this one. Where do I put the code?

 

Thanks

Link to comment
Share on other sites

I checked the orders.php file 10 times and couldn't find a line that resemble this one. Where do I put the code?

 

Did you modify this orders.php file while installing another contribution? This line is in the default version of this file on a regular MS2 installation.

 

Try to find the following, around line 353:

 

<?php
if (isset($HTTP_GET_VARS['cID'])) {
  $cID = tep_db_prepare_input($HTTP_GET_VARS['cID']);
  $orders_query_raw = "select o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s where o.customers_id = '" . (int)$cID . "' and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by orders_id DESC";

 

the line you were looking for should be right below it, and the code to insert for this contribution should come in between.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...