Zen Cart Logo
Forums / Managing Customers and Orders / Addin Repeat Customers in Admin -> Customers -> Orders.php

Addin Repeat Customers in Admin -> Customers -> Orders.php

Views: 1,804

Results 1 to 4 of 4
24 Feb 2014, 12:27 AM
#1
fabburl avatar

fabburl

New Zenner

Join Date:
Sep 2012
Posts:
18
Plugin Contributions:
0

Addin Repeat Customers in Admin -> Customers -> Orders.php

Couldn't find much info that was helpful in the forums regarding this issue.

Essentially I would like to update the admin/orders.php page to display another row (e.g., between the "Status" row and "Customer Comments") that would display the total # of orders made by that customer (so a row called "Total Orders"). I would like this because it would allow me to quickly see immediately whether or not a customer is a repeat customer and how many orders they have made and whether I should prioritize shipping to them. Not that much different than the admin/stats_customers.php file.

What steps are involved in this? I can accomplish counting total number of orders per customer in my MySQL database by doing a COUNT and GROUP function but I am lost in trying to implement this on the admin/orders.php page.

If anyone has faced this issue before and has any solutions/plug-ins to help with this issue I would greatly appreciate it.

24 Feb 2014, 3:50 AM
#2
twitchtoo avatar

twitchtoo

Totally Zenned

Join Date:
Apr 2007
Location:
Ontario, Canada
Posts:
1,733
Plugin Contributions:
14

Re: Addin Repeat Customers in Admin -> Customers -> Orders.php

You'll need:
2oz of rye... wait... ;)

If there isn't already an order total SQL query, you'll need to make one.

It will tally up the orders by customer and output the total.

The rest is remarkably easy... output the number beside a newly defined CUST_ORDERS_TOTAL in the right side split summary.

24 Feb 2014, 5:22 AM
#3
davewest avatar

davewest

Totally Zenned

Join Date:
Dec 2007
Location:
Payson, AZ
Posts:
1,075
Plugin Contributions:
7

Re: Addin Repeat Customers in Admin -> Customers -> Orders.php

fabburl:

Couldn't find much info that was helpful in the forums regarding this issue.

Essentially I would like to update the admin/orders.php page to display another row (e.g., between the "Status" row and "Customer Comments") that would display the total # of orders made by that customer (so a row called "Total Orders"). I would like this because it would allow me to quickly see immediately whether or not a customer is a repeat customer and how many orders they have made and whether I should prioritize shipping to them. Not that much different than the admin/stats_customers.php file.

What steps are involved in this? I can accomplish counting total number of orders per customer in my MySQL database by doing a COUNT and GROUP function but I am lost in trying to implement this on the admin/orders.php page.

If anyone has faced this issue before and has any solutions/plug-ins to help with this issue I would greatly appreciate it.

simple to do by record counting...
Add a define at the bottom of admin/lincludes/languages/english/orders.php

define('TABLE_HEADING_TOTAL_ORDERS', 'Total Orders');

in admin/orders.php add two section of code (line numers may be differnt in your version then mine due to addons) around line 792.. add the bold red line of code.

      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_STATUS; ?></td>
                [B]<td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_TOTAL_ORDERS; ?></td>[/B]
                <td class="dataTableHeadingContent" align="center"><?php echo TABLE_HEADING_CUSTOMER_COMMENTS; ?></td>

Around line 916 add the bold line

                <td class="dataTableContent" align="right"><?php echo $orders->fields['orders_status_name']; ?></td>
                [B]<td class="dataTableContent" align="center"><?php
                $customers_orders = $db->Execute("select orders_id, date_purchased, customers_id from " . TABLE_ORDERS . " where customers_id='" . $orders->fields['customers_id'] . "' order by date_purchased desc");
                echo $customers_orders->RecordCount() ; ?></td>[/B]
                <td class="dataTableContent" align="center"><?php echo (zen_get_orders_comments($orders->fields['orders_id']) == '' ? '' : zen_image(DIR_WS_IMAGES . 'icon_yellow_on.gif', TEXT_COMMENTS_YES, 16, 16)); ?></td>

if you don't use an editor that auto backs up your file, then make sure you create a backup before you begin editing!

25 Feb 2014, 4:05 AM
#4
fabburl avatar

fabburl

New Zenner

Join Date:
Sep 2012
Posts:
18
Plugin Contributions:
0

Re: Addin Repeat Customers in Admin -> Customers -> Orders.php

Awesome, thanks Dave! very easily implemented and works perfectly despite me being a newbie to php and mysql. Only thing that is confusing me is that the table the customer orders count is appearing is has the text "Customer Comments" - although that is a minor problem. Perhaps that is because I have the SuperOrders plugin already installed. I will test out on a fresh install.

Now that I have the code I think I am going to put it on other files.