__( 'Year', 'woocommerce' ), 'last_month' => __( 'Last Month', 'woocommerce' ), 'month' => __( 'This Month', 'woocommerce' ), ); $current_range = ! empty( $_GET['range'] ) ? sanitize_text_field( $_GET['range'] ) : 'last_month'; if ( ! in_array( $current_range, array( 'custom', 'year', 'last_month', 'month', '7day' ) ) ) { $current_range = 'last_month'; } $this->calculate_current_range( $current_range ); $hide_sidebar = true; include( WC()->plugin_path() . '/includes/admin/views/html-report-by-date.php'); } /** * Get the main chart * * @return string */ public function get_main_chart() { $query_data = array( '_order_tax' => array( 'type' => 'meta', 'function' => 'SUM', 'name' => 'tax_amount' ), '_order_shipping_tax' => array( 'type' => 'meta', 'function' => 'SUM', 'name' => 'shipping_tax_amount' ), '_order_total' => array( 'type' => 'meta', 'function' => 'SUM', 'name' => 'total_sales' ), '_order_shipping' => array( 'type' => 'meta', 'function' => 'SUM', 'name' => 'total_shipping' ), 'ID' => array( 'type' => 'post_data', 'function' => 'COUNT', 'name' => 'total_orders', 'distinct' => true, ), 'post_date' => array( 'type' => 'post_data', 'function' => '', 'name' => 'post_date' ), ); $tax_rows_orders = $this->get_order_report_data( array( 'data' => $query_data, 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => wc_get_order_types( 'sales-reports' ), 'order_status' => array( 'completed', 'processing', 'on-hold' ) ) ); $tax_rows_partial_refunds = $this->get_order_report_data( array( 'data' => $query_data, 'group_by' => $this->group_by_query, 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true, 'order_types' => array( 'shop_order_refund' ), 'parent_order_status' => array( 'completed', 'processing', 'on-hold' ) // Partial refunds inside refunded orders should be ignored ) ); // Merge $tax_rows = array(); foreach ( $tax_rows_orders as $tax_row ) { $key = date( $this->chart_groupby == 'month' ? 'Ym' : 'Ymd', strtotime( $tax_row->post_date ) ); $tax_rows[ $key ] = isset( $tax_rows[ $key ] ) ? $tax_rows[ $key ] : (object) array( 'tax_amount' => 0, 'shipping_tax_amount' => 0, 'total_sales' => 0, 'total_shipping' => 0, 'total_orders' => 0 ); $tax_rows[ $key ]->tax_amount += $tax_row->tax_amount; $tax_rows[ $key ]->shipping_tax_amount += $tax_row->shipping_tax_amount; $tax_rows[ $key ]->total_sales += $tax_row->total_sales; $tax_rows[ $key ]->total_shipping += $tax_row->total_shipping; $tax_rows[ $key ]->total_orders += $tax_row->total_orders; } foreach ( $tax_rows_partial_refunds as $tax_row ) { $key = date( $this->chart_groupby == 'month' ? 'Ym' : 'Ymd', strtotime( $tax_row->post_date ) ); $tax_rows[ $key ] = isset( $tax_rows[ $key ] ) ? $tax_rows[ $key ] : (object) array( 'tax_amount' => 0, 'shipping_tax_amount' => 0, 'total_sales' => 0, 'total_shipping' => 0, 'total_orders' => 0 ); $tax_rows[ $key ]->tax_amount += $tax_row->tax_amount; $tax_rows[ $key ]->shipping_tax_amount += $tax_row->shipping_tax_amount; $tax_rows[ $key ]->total_sales += $tax_row->total_sales; $tax_rows[ $key ]->total_shipping += $tax_row->total_shipping; } ?> $tax_row ) { $gross = $tax_row->total_sales - $tax_row->total_shipping; $total_tax = $tax_row->tax_amount + $tax_row->shipping_tax_amount; ?>
chart_groupby == 'month' ) echo date_i18n( 'F', strtotime( $date . '01' ) ); else echo date_i18n( get_option( 'date_format' ), strtotime( $date ) ); ?> total_orders; ?> total_shipping ); ?>