__( 'Year', 'woocommerce' ), 'last_month' => __( 'Last Month', 'woocommerce' ), 'month' => __( 'This Month', 'woocommerce' ), ); $current_range = ! empty( $_GET['range'] ) ? $_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() { global $wpdb; $tax_rows = $this->get_order_report_data( array( 'data' => array( 'order_item_name' => array( 'type' => 'order_item', 'function' => '', 'name' => 'tax_rate' ), 'tax_amount' => array( 'type' => 'order_item_meta', 'order_item_type' => 'tax', 'function' => '', 'name' => 'tax_amount' ), 'shipping_tax_amount' => array( 'type' => 'order_item_meta', 'order_item_type' => 'tax', 'function' => '', 'name' => 'shipping_tax_amount' ), 'rate_id' => array( 'type' => 'order_item_meta', 'order_item_type' => 'tax', 'function' => '', 'name' => 'rate_id' ), 'order_id' => array( 'type' => 'order_item', 'function' => '', 'name' => 'order_id' ) ), 'where' => array( array( 'key' => 'order_item_type', 'value' => 'tax', 'operator' => '=' ), array( 'key' => 'order_item_name', 'value' => '', 'operator' => '!=' ) ), 'order_by' => 'post_date ASC', 'query_type' => 'get_results', 'filter_range' => true ) ); ?> rate_id ] ) ) { $grouped_tax_tows[ $tax_row->rate_id ] = (object) array( 'tax_rate' => $tax_row->tax_rate, 'total_orders' => 0, 'tax_amount' => 0, 'shipping_tax_amount' => 0 ); } if ( 'shop_order' === get_post_type( $tax_row->order_id ) ) { $grouped_tax_tows[ $tax_row->rate_id ]->total_orders ++; } $grouped_tax_tows[ $tax_row->rate_id ]->tax_amount += wc_round_tax_total( $tax_row->tax_amount ); $grouped_tax_tows[ $tax_row->rate_id ]->shipping_tax_amount += wc_round_tax_total( $tax_row->shipping_tax_amount ); } foreach ( $grouped_tax_tows as $rate_id => $tax_row ) { $rate = $wpdb->get_var( $wpdb->prepare( "SELECT tax_rate FROM {$wpdb->prefix}woocommerce_tax_rates WHERE tax_rate_id = %d;", $rate_id ) ); ?>
" href="#">[?] " href="#">[?] [?]
tax_rate; ?> % total_orders; ?> tax_amount ); ?> shipping_tax_amount ); ?> tax_amount + $tax_row->shipping_tax_amount ); ?>