Pass order_types to reporting query functions

This commit is contained in:
Mike Jolley 2014-07-24 15:55:06 +01:00
parent 19b6922044
commit 873f36ca5c
2 changed files with 18 additions and 9 deletions

View File

@ -47,7 +47,8 @@ class WC_Admin_Report {
'limit' => '',
'filter_range' => false,
'nocache' => false,
'debug' => false
'debug' => false,
'order_types' => wc_get_order_types( 'reports' )
);
$args = apply_filters( 'woocommerce_reports_get_order_report_data_args', wp_parse_args( $args, $defaults ) );
@ -128,7 +129,7 @@ class WC_Admin_Report {
$query['join'] = implode( ' ', $joins );
$query['where'] = "
WHERE posts.post_type IN ( '" . implode( "','", wc_get_order_types( 'reports' ) ) . "' )
WHERE posts.post_type IN ( '" . implode( "','", $order_types ) . "' )
AND posts.post_status IN ( 'wc-" . implode( "','wc-", apply_filters( 'woocommerce_reports_order_statuses', array( 'completed', 'processing', 'on-hold' ) ) ) . "')
";

View File

@ -29,18 +29,24 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
'type' => 'meta',
'function' => 'SUM',
'name' => 'total_shipping'
),
'ID' => array(
'type' => 'post_data',
'function' => 'COUNT',
'name' => 'total_orders'
)
),
'filter_range' => true
) );
$total_sales = $order_totals->total_sales;
$total_shipping = $order_totals->total_shipping;
$total_orders = absint( $order_totals->total_orders );
$total_orders = absint( $this->get_order_report_data( array(
'data' => array(
'ID' => array(
'type' => 'post_data',
'function' => 'COUNT',
'name' => 'total_orders'
)
),
'query_type' => 'get_var',
'filter_range' => true,
'order_types' => wc_get_order_types( 'order-count' )
) ) );
$total_items = absint( $this->get_order_report_data( array(
'data' => array(
'_qty' => array(
@ -51,6 +57,7 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
)
),
'query_type' => 'get_var',
'order_types' => wc_get_order_types( 'order-count' ),
'filter_range' => true
) ) );
// Get discount amounts in range
@ -70,7 +77,8 @@ class WC_Report_Sales_By_Date extends WC_Admin_Report {
'operator' => '='
)
),
'query_type' => 'get_var',
'query_type' => 'get_var',
'order_types' => wc_get_order_types( 'order-count' ),
'filter_range' => true
) );