Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Customer Order Count


JR Bregante

Recommended Posts

Hello,

 

I would like to have when viewing Admin/Orders next to each persons name the amount of times they have ordered. Such as John Doe (7). Can someone please let me know what the code I need to add for this function. Greatly appreciated.

 

Thanks JR

Link to comment
Share on other sites

Hi,

 

In admin/orders.php around line 371 find the following set of code

 

      }

?>

               <td class="dataTableContent" align="right"><?php tep_get_all_get_params(array('oID')); echo $orders['orders_id']; ?></td>

   <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>

               <td class="dataTableContent" align="right"><?php echo strip_tags($orders['order_total']); ?></td>

               <td class="dataTableContent" align="center"><?php echo tep_datetime_short($orders['date_purchased']); ?></td>

               <td class="dataTableContent" align="right"><?php echo $orders['orders_status_name']; ?></td>

               <td class="dataTableContent" align="right"><?php if ( (is_object($oInfo)) && ($orders['orders_id'] == $oInfo->orders_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID')) . 'oID=' . $orders['orders_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>

             </tr>

 

and replace with.....

 

      }

  

$freq_info = tep_db_query("select count(*) as count from " . TABLE_ORDERS . " where customers_id = '" . $orders_query['customers_id'] . "'");

   $freq_value = tep_db_fetch_array($freq_info);

?>

               <td class="dataTableContent" align="right"><?php tep_get_all_get_params(array('oID')); echo $orders['orders_id']; ?></td>

   <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']; ?> (<?php echo $freq_value['count']; ?>)</td>

               <td class="dataTableContent" align="right"><?php echo strip_tags($orders['order_total']); ?></td>

               <td class="dataTableContent" align="center"><?php echo tep_datetime_short($orders['date_purchased']); ?></td>

               <td class="dataTableContent" align="right"><?php echo $orders['orders_status_name']; ?></td>

               <td class="dataTableContent" align="right"><?php if ( (is_object($oInfo)) && ($orders['orders_id'] == $oInfo->orders_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID')) . 'oID=' . $orders['orders_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td>

             </tr>

 

You should now have the number of orders in brackets next to the customers name! :)

 

#Back up before you try and let me know how it goes!

Reddy to Rumble

 

Thank you osCommerce and all who Contribute to her!

Link to comment
Share on other sites

Update: It should have been.....

 

      } 

    

  $freq_info = tep_db_query("select count(*) as count from " . TABLE_ORDERS . " where customers_id = '" . $orders['customers_id'] . "'"); 

   $freq_value = tep_db_fetch_array($freq_info); 

?> 

               <td class="dataTableContent" align="right"><?php tep_get_all_get_params(array('oID')); echo $orders['orders_id']; ?></td> 

           <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']; ?> (<?php echo $freq_value['count']; ?>)</td> 

               <td class="dataTableContent" align="right"><?php echo strip_tags($orders['order_total']); ?></td> 

               <td class="dataTableContent" align="center"><?php echo tep_datetime_short($orders['date_purchased']); ?></td> 

               <td class="dataTableContent" align="right"><?php echo $orders['orders_status_name']; ?></td> 

               <td class="dataTableContent" align="right"><?php if ( (is_object($oInfo)) && ($orders['orders_id'] == $oInfo->orders_id) ) { echo tep_image(DIR_WS_IMAGES . 'icon_arrow_right.gif', ''); } else { echo '<a href="' . tep_href_link(FILENAME_ORDERS, tep_get_all_get_params(array('oID')) . 'oID=' . $orders['orders_id']) . '">' . tep_image(DIR_WS_IMAGES . 'icon_info.gif', IMAGE_ICON_INFO) . '</a>'; } ?> </td> 

             </tr>

 

Plus above this set of code there are 3 lines of code starting off like:

 

$orders_query_raw = "select o.orders_id, o.customers_name, o.customers_id, o.payment_method,.............

 

make sure all three lines contain the 'o.customers_id' bit!!

 

Back up before you try!!!

Reddy to Rumble

 

Thank you osCommerce and all who Contribute to her!

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...