Forums / Managing Customers and Orders / adding "Number of Orders" field

adding "Number of Orders" field

Locked

Views: 1,652

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
1 Nov 2007, 6:58 PM
#1
davidhwalker avatar

davidhwalker

New Zenner

Join Date:
Jun 2006
Location:
Austin, TX
Posts:
25
Plugin Contributions:
0

adding "Number of Orders" field

Searched but couldn't find an answer for this one...

In the admin section when you're going through your customers there's a box on the right with the field, Number of Orders.

When you're going through the orders, though, there is a different box with different fields. (Date Created, email, IP address, etc.)

I would like to insert the "Number of Orders" field into that right side box. How do I do this?

Thanks!

29 Apr 2008, 6:53 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: adding "Number of Orders" field

While a given order doesn't technically relate to how many orders a given customer has placed, if you want to place that statistic on the sidebar of a given order, you can probably do it by adding the following code, as shown, to /admin/orders.php.

Around line 850 you'll see this section. Make the additions shown:```
default:
if (isset($oInfo) && is_object($oInfo)) {
$heading[] = array('text' => '<strong>[' . $oInfo->orders_id . ']  ' . zen_datetime_short($oInfo->date_purchased) . '</strong>');

    $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=edit', 'NONSSL') . '">' . zen_image_button('button_edit.gif', IMAGE_EDIT) . '</a> <a href="' . zen_href_link(FILENAME_ORDERS, zen_get_all_get_params(array('oID', 'action')) . 'oID=' . $oInfo->orders_id . '&action=delete', 'NONSSL') . '">' . zen_image_button('button_delete.gif', IMAGE_DELETE) . '</a>');
    $contents[] = array('align' => 'center', 'text' => '<a href="' . zen_href_link(FILENAME_ORDERS_INVOICE, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . zen_image_button('button_invoice.gif', IMAGE_ORDERS_INVOICE) . '</a> <a href="' . zen_href_link(FILENAME_ORDERS_PACKINGSLIP, 'oID=' . $oInfo->orders_id) . '" TARGET="_blank">' . zen_image_button('button_packingslip.gif', IMAGE_ORDERS_PACKINGSLIP) . '</a>');
    $contents[] = array('text' => '<br />' . TEXT_DATE_ORDER_CREATED . ' ' . zen_date_short($oInfo->date_purchased));
    $contents[] = array('text' => '<br />' . $oInfo->customers_email_address);

[B] $customers_orders = $db->Execute("select count(orders_id) as num_orders
from " . TABLE_ORDERS . " o
where customers_id='" . $oInfo->customers_id . "'");
$contents[] = array('text' => '<br />' . TEXT_INFO_NUMBER_OF_ORDERS . ' ' . $customers_orders->fields['num_orders']);[/B]

$contents[] = array('text' => TEXT_INFO_IP_ADDRESS . ' ' . $oInfo->ip_address);
if (zen_not_null($oInfo->last_modified)) $contents[] = array('text' => TEXT_DATE_ORDER_LAST_MODIFIED . ' ' . zen_date_short($oInfo->last_modified));
$contents[] = array('text' => '<br />' . TEXT_INFO_PAYMENT_METHOD . ' ' . $oInfo->payment_method);
$contents[] = array('text' => '<br />' . ENTRY_SHIPPING . ' ' . $oInfo->shipping_method);


You'll need to add a define for TEXT_INFO_NUMBER_OF_ORDERS to the language file as well.




I basically just copied the sidebar code from the customers.php file and adapted with a couple minor modifications for the orders.php file.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

29 Apr 2008, 1:45 PM
#3
davidhwalker avatar

davidhwalker

New Zenner

Join Date:
Jun 2006
Location:
Austin, TX
Posts:
25
Plugin Contributions:
0

Re: adding "Number of Orders" field

Thanks for the reply. What do you mean "order numbers" doesn't technically relate to the # of orders placed?

30 Apr 2008, 4:23 AM
#4
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
176

Re: adding "Number of Orders" field

davidhwalker:

What do you mean "order numbers" doesn't technically relate to the # of orders placed?

Strictly speaking, an order is an order. The existence of other orders in the database is irrelevant to that particular order.
The sidebar normally displays information pertinent to the highlighted order.
The number of other orders placed by that customer has no relevance to the details of the highlighted order.

That's all.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.