Created
September 30, 2014 16:50
-
-
Save drrobotnik/b1bbe34766f129171b02 to your computer and use it in GitHub Desktop.
Use Woo Admin Reports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include_once(ABSPATH . 'wp-content/plugins/woocommerce/includes/admin/reports/class-wc-admin-report.php'); | |
$report = new WC_Admin_Report(); | |
$start_date = get_field('campaign_start_date', $campaign->ID); | |
$end_date = get_field('campaign_end_date', $campaign->ID); | |
$report->start_date = strtotime($start_date); | |
$report->end_date = strtotime($end_date); | |
$args = array( | |
'data' => array( | |
'_order_total' => array( | |
'type' => 'meta', | |
'function' => 'SUM', | |
'name' => 'total_sales' | |
) | |
), | |
// add filter to return results containing a particular meta key/value | |
'where_meta' => array( | |
array( | |
'meta_key' => 'cause', | |
'meta_value' => $post->ID, | |
'operator' => '=' | |
) | |
), | |
'filter_range' => true, | |
'debug' => false | |
); | |
$order_totals = $report->get_order_report_data( $args ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment