Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

how do i know if someone ordered?


Guest

Recommended Posts

Posted

i'm trying to output # of order's for the customer's ID

 

here's the query i'm using:

  $siu_query_raw = "select ci.customers_info_date_of_last_logon, c.customers_id, c.customers_firstname, c.customers_lastname, c.customers_email_address, c.customers_newsletter, c.customers_telephone from " . TABLE_CUSTOMERS_INFO . " ci, " . TABLE_CUSTOMERS . " c left join " . TABLE_ORDERS . " o on c.customers_id = o.customers_id where o.customers_id is NULL and c.customers_id = ci.customers_info_id order by c.customers_id";
 $siu_split = new splitPageResults($HTTP_GET_VARS['page'], MAX_DISPLAY_SEARCH_RESULTS, $siu_query_raw, $siu_query_numrows );
 $siu_query = tep_db_query($siu_query_raw);
 while ($customers = tep_db_fetch_array($siu_query)) {

Posted

Here is a query code example:

 

<?php

 

$info_query = tep_db_query("select customers_info_date_account_created as date_account_created, customers_info_date_account_last_modified as date_account_last_modified, customers_info_date_of_last_logon as date_last_logon, customers_info_number_of_logons as number_of_logons from " . TABLE_CUSTOMERS_INFO . " where customers_info_id = '" . (int)$customers['customers_id'] . "'");

$info = tep_db_fetch_array($info_query);

$country_query = tep_db_query("select countries_name from " . TABLE_COUNTRIES . " where countries_id = '" . (int)$customers['entry_country_id'] . "'");

$country = tep_db_fetch_array($country_query);

 

$reviews_query = tep_db_query("select count(*) as number_of_reviews from " . TABLE_REVIEWS . " where customers_id = '" . (int)$customers['customers_id'] . "'");

$reviews = tep_db_fetch_array($reviews_query);

 

$orderhistory_query = tep_db_query("select count(*) as number_of_orders_history from " . TABLE_ORDERS . " where customers_id = '" . (int)$customers['customers_id'] . "'");

$orderhistory = tep_db_fetch_array($orderhistory_query);

 

$customer_info = array_merge($country, $info, $reviews, $orderhistory);

 

$cInfo_array = array_merge($customers, $customer_info);

$cInfo = new objectInfo($cInfo_array);

?>

 

To display the orders total per customer use this output:

 

<tr>

<td class="main" width="25%"><?php echo TEXT_ORDER_HISTORY; ?></td>

<td class="main"><?php echo $orderhistory['number_of_orders_history']; ?></td>

</tr>

 

 

That should get you started.

Posted

For just displaying the number of orders per customer you really only need this part.

 

Here is a query code example:

 

<?php

$orderhistory_query = tep_db_query("select count(*) as number_of_orders_history from " . TABLE_ORDERS . " where customers_id = '" . (int)$customers['customers_id'] . "'");

$orderhistory = tep_db_fetch_array($orderhistory_query);

?>

 

To display the orders total per customer use this output:

 

<tr>

<td class="main" width="25%"><?php echo TEXT_ORDER_HISTORY; ?></td>

<td class="main"><?php echo $orderhistory['number_of_orders_history']; ?></td>

</tr>

 

 

That should get you started.

Posted

thanks i tried that, and it's outputting zero for everybody, even my test account that i just made a purchase with

 

i'm trying to use it in conjunction with the first query i posted, because i use it to delete users that registered and won't accept newlestters.. but never made a complete purchase.

 

if i were able to get the order count into this query it would save a load of time, so i wouldn't have to manually search every customer that has "no" marked to the newsletter

Archived

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

×
×
  • Create New...