I love this module! Found a small bug, though, which is that its default blocks make mistakes if there are any custom order statuses (as provided by commerce_custom_order_status module.

Here's my setup: My client upgraded from Ubercart and asked me to add 2 custom statuses that Ubercart has by default: "Payment Received" and "PayPal Pending". I set up rules that put a completed order into "Payment Received" (as opposed to "Pending", which is the default) if payment goes through normally, and "PayPal Pending" if the buyer uses PayPal eCheck. However, this module's default blocks only record orders in the default "Pending" and "Completed" statuses.

So I added code that modifies the queries in commerce_reports.blocks.inc to check for custom statuses. Here it is (within function commerce_reports_customers()):

// Query to find custom 'pending' statuses and append them to 'completed' and 'pending'.
$status_names = "'completed', 'pending'";
  
$query = db_select('commerce_custom_order_status', 'c');
$query->fields('c', array('name', 'state'));
$query->condition('c.state', 'pending', '=');
$get_pending_statuses = $query->execute();
foreach($get_pending_statuses as $pending_status) {
	$status_names .= ", '" . $pending_status->name . "'";
}

Then, in the queries (i.e. beginning with $total_customers), here's an example:

$total_customers = db_query("SELECT COUNT(uid) FROM (SELECT u.uid AS uid FROM {users} u INNER JOIN {commerce_order} o ON u.uid = o.uid WHERE o.status IN (" . $status_names . ") GROUP BY o.uid) s")->fetchField();

Note $status_names in the IN() criterion within the WHERE clause, as opposed to the hard-coded status names.

Comments

visuaLatte’s picture

Clarification: my fix above only fixes the "Customer Statistics" block.

The other blocks can be changed via Views.

visuaLatte’s picture

Issue summary: View changes

Edited query.

mglaman’s picture

Issue summary: View changes
Status: Active » Postponed (maintainer needs more info)

Can you please try the 4.x branch? The 4.x branch is using Order State, pending and complete. This should resolve any custom status issues.

mglaman’s picture

mglaman’s picture

Version: 7.x-3.0-beta2 » 7.x-4.x-dev
Status: Postponed (maintainer needs more info) » Fixed

4.x uses states versus status.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.