Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Adding customer rank to customers.php


shedcade

Recommended Posts

Hi all

 

i love being able to view the customers who have ordered the most (and seeing their rank in the left column). Can anyone help me attach this rank to the customer and display it alongside their details in admin/customers.php?

 

The code is from stats_customers, can it be modified and re-used, all help greatly appreciated!

 

$customers_query_raw = "select c.customers_firstname, c.customers_lastname, sum(op.products_quantity * op.final_price) as ordersum from " . TABLE_CUSTOMERS . " c, " . TABLE_ORDERS_PRODUCTS . " op, " . TABLE_ORDERS . " o where c.customers_id = o.customers_id and o.orders_id = op.orders_id group by c.customers_firstname, c.customers_lastname order by ordersum DESC";
 $customers_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $customers_query_raw, $customers_query_numrows);
// fix counted customers
 $customers_query_numrows = tep_db_query("select customers_id from " . TABLE_ORDERS . " group by customers_id");
 $customers_query_numrows = tep_db_num_rows($customers_query_numrows);

 $rows = 0;
 $customers_query = tep_db_query($customers_query_raw);
 while ($customers = tep_db_fetch_array($customers_query)) {
   $rows++;

   if (strlen($rows) < 2) {
     $rows = '0' . $rows;
   }

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...