Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

See Customer Order History in Admin/Orders


b2995

Recommended Posts

Posted

Just wondering if there was a contribution or if anyone knew how to do this...

 

Is there a way to have a customer's name show as a link if they're a repeat customer? It'd be cool if I could click on the customer's name and it take me to their history. Or for it to show a number (ex... John Doe (10) ) after the customer's name on how many orders they previously placed.

 

Thanks!

:)

Posted

Tammy,

 

It's a good idea but doesn't seem it has been done before. Perhaps someone will find the time to create this feature.

 

 

 

 

Chris

Posted

Here is a mod I use that reports the customers number of orders, it is based on the customer's email address:

Please report back any suggestions or edits and I will then publish this update. I updated it to link to the customers page, but it only finds customers who have an account.

 

Here is the published version without the customer link

http://addons.oscommerce.com/info/7102

 

Customer_Number_Of_Orders v1.0 by pyramids

 

This simple mod will show the total number of orders placed by each customer. The number will show on the orders.php listing page, just to the left of the name something like - #7 "preview" John Smith, where #7 is the number of orders placed by this customer (customers unique email address). The "Number" is linked to a search of the customers email address to show their orders.

 

I find it useful to know how many orders were placed by the customer, especially if they ask for a discount.

 

 

#######################

# IN admin/orders.php #

#######################

 

***FIND***

<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $orders['customers_name']; ?></td>

 

 

***CHANGE TO***

<!-- bof number of orders for each customer -->
<?php
$get_email_address = tep_db_query("select customers_email_address from " . TABLE_ORDERS . " where orders_id = '" . (int)$orders['orders_id'] . "'");
$this_email_address = tep_db_fetch_array($get_email_address);

$check_numberof_orders= tep_db_query("select count(orders_id) as total_ord from " . TABLE_ORDERS . " where customers_email_address = '" . $this_email_address['customers_email_address'] . "'");
$getit = tep_db_fetch_array($check_numberof_orders);
$all_orders = $getit['total_ord'];
?>
<td class="dataTableContent">
<?php
echo '<a href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params() . 'search=' . $orders['customers_email_address']). '">#' . $all_orders ."</a> ";
echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $orders['customers_name'];
?></td>
<!-- eof number of orders for each customer -->

Posted

Thanks for the quick response Jeff! I can't get the search part to work...just goes straight to the Customer page...but just knowing a customer is a repeat customer so I can "welcome them back" is GREAT!

 

Here's the search result ...catalog/admin/customers.php?page=1&search=

 

Jeff or if anyone else has any suggestions, I'd love to try it out, but I'm happy with the above too :) Thanks!!!

Posted

To fix the link, try this change:

(note - it will only show customers with an account)

 

find

echo '<a href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params() . 'search=' . $orders['customers_email_address']). '">#' . $all_orders ."</a> ";

 

change to:

echo '<a href="' . tep_href_link(FILENAME_CUSTOMERS, tep_get_all_get_params() . 'search=' . $this_email_address['customers_email_address']). '">#' . $all_orders ."</a> ";

 

 

My orders.php is modified to show the following:

 

KEY:

[[Customer]] = Banned Email;

Blue Customer = Not USA;

[D] = Discount;

* = Has Account;

[P] = Phone Order;

[P] = Print Order/Pkg Slip [link];

= USPS Label [link];

(L) = Print Label [link];

v,m,a,d = credit card used;

# of orders placed;

DBL = Duplicate Charge

 

If anyone is interested in these let me know.

Posted

Slightly different method;

 

Add this to /admin/includes/functions/general.php:

 

function clubosc_get_number_orders($customer_id) {
   $cust_query = tep_db_query("select COUNT(orders_id) as total_orders from " . TABLE_ORDERS . " where customers_id = '" . (int)$customer_id . "'");
   $cust = tep_db_fetch_array($cust_query);

   if ($cust['total_orders'] > 0) return ' [<a href="' . tep_href_link(FILENAME_ORDERS, 'cID=' . (int)$customer_id) . '">' . $cust['total_orders'] . '</a>]';
}

 

Amend admin/customers.php from this:

 

<td class="dataTableContent"><?php echo $customers['customers_lastname']; ?></td>

 

to this:

 

<td class="dataTableContent"><?php echo $customers['customers_lastname'] . clubosc_get_number_orders($customers['customers_id']); ?></td>

Posted

Amend admin/orders.php from this:

 

      $orders_query_raw = "select o.orders_id, o.customers_name, 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.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total' order by o.orders_id DESC";
   } else {
     $orders_query_raw = "select o.orders_id, o.customers_name, 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.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by o.orders_id DESC";

 

to this:

 

      $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.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total' order by o.orders_id DESC";
   } else {
     $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.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and ot.class = 'ot_total' order by o.orders_id DESC";

 

Basically adding o.customers_id into BOTH sql queries.

 

And amend (same file) from this:

 

<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $orders['customers_name']; ?></td>

 

to this:

 

<td class="dataTableContent"><?php echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID', 'action')) . 'oID=' . $orders['orders_id'] . '&action=edit') . '">' . tep_image(DIR_WS_ICONS . 'preview.gif', ICON_PREVIEW) . '</a> ' . $orders['customers_name'] . clubosc_get_number_orders($orders['customers_id']); ?></td>

Posted

Jeff - that did the trick! Very simple and easy! Thanks again!!! :thumbsup:

 

Burt - thanks for the additional post! When i have time, I'll try yours out as well, but I'm sure both will be very helpful to many. :)

Archived

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

×
×
  • Create New...