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
Comment #1
visuaLatte commentedClarification: my fix above only fixes the "Customer Statistics" block.
The other blocks can be changed via Views.
Comment #1.0
visuaLatte commentedEdited query.
Comment #2
mglamanCan 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.
Comment #3
mglamanComment #4
mglaman4.x uses states versus status.