Changeset 1189764
- Timestamp:
- 06/29/2015 05:52:10 PM (10 years ago)
- Location:
- woocommerce-sales-by-location-report/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-sales-by-location-report/trunk/changelog.txt
r1065346 r1189764 1 1 *** WooCommerce Sales By Location Report Changelog *** 2 3 2015.XX.XX - Version 1.2 4 * Fix - Fix order total reporting issue with WooCommerce 2.3 2 5 3 6 2015.01.11 - Version 1.1.1 -
woocommerce-sales-by-location-report/trunk/classes/class-wc-report-sales-by-location.php
r1029435 r1189764 17 17 public $totals_by; 18 18 19 private $report_data; 20 21 22 /** 23 * Get report data 24 * @return array 25 */ 26 public function get_report_data() { 27 if ( empty( $this->report_data ) ) { 28 $this->query_report_data(); 29 } 30 return $this->report_data; 31 } 32 33 /** 34 * Get all data needed for this report and store in the class 35 */ 36 private function query_report_data() { 37 38 $this->report_data = new stdClass; 39 40 $this->report_data->orders = (array) $this->get_order_report_data( array( 41 'data' => array( 42 '_' . $this->location_by . '_country' => array( 43 'type' => 'meta', 44 'name' => 'countries_data', 45 'function' => null 46 ), 47 '_order_total' => array( 48 'type' => 'meta', 49 'function' => 'SUM', 50 'name' => 'total_sales' 51 ), 52 'post_date' => array( 53 'type' => 'post_data', 54 'function' => '', 55 'name' => 'post_date' 56 ), 57 ), 58 'group_by' => 'YEAR(posts.post_date), MONTH(posts.post_date), DAY(posts.post_date), meta__' . $this->location_by . '_country.meta_value', 59 'order_by' => 'post_date ASC', 60 'query_type' => 'get_results', 61 'filter_range' => true, 62 'order_types' => array_merge( array( 'shop_order_refund' ), wc_get_order_types( 'sales-reports' ) ), 63 'order_status' => array( 'completed', 'processing', 'on-hold' ), 64 'parent_order_status' => array( 'completed', 'processing', 'on-hold' ), 65 ) ); 66 67 $this->report_data->order_counts = (array) $this->get_order_report_data( array( 68 'data' => array( 69 '_' . $this->location_by . '_country' => array( 70 'type' => 'meta', 71 'name' => 'countries_data', 72 'function' => null 73 ), 74 'ID' => array( 75 'type' => 'post_data', 76 'function' => 'COUNT', 77 'name' => 'count', 78 'distinct' => true, 79 ), 80 'post_date' => array( 81 'type' => 'post_data', 82 'function' => '', 83 'name' => 'post_date' 84 ) 85 ), 86 'group_by' => 'YEAR(posts.post_date), MONTH(posts.post_date), DAY(posts.post_date), meta__' . $this->location_by . '_country.meta_value', 87 'order_by' => 'post_date ASC', 88 'query_type' => 'get_results', 89 'filter_range' => true, 90 'order_types' => wc_get_order_types( 'order-count' ), 91 'order_status' => array( 'completed', 'processing', 'on-hold' ) 92 ) ); 93 94 } 95 19 96 /** 20 97 * Get the legend for the main chart sidebar … … 28 105 $this->totals_by = ( isset($_REQUEST['report_by']) ? $_REQUEST['report_by'] : 'number-orders' ); 29 106 107 108 $data = $this->get_report_data(); 109 30 110 add_filter( 'woocommerce_reports_get_order_report_query', array( $this, 'location_report_add_count' ) ); 31 32 $location_query = $this->get_order_report_data( array(33 'data' => array(34 '_' . $this->location_by . '_country' => array(35 'type' => 'meta',36 'name' => 'countries_data',37 'function' => null38 ),39 '_order_total' => array(40 'type' => 'meta',41 'function' => 'SUM',42 'name' => 'total_sales'43 ),44 'post_date' => array(45 'type' => 'post_data',46 'function' => '',47 'name' => 'post_date'48 ),49 ),50 'filter_range' => true,51 'group_by' => 'YEAR(posts.post_date), MONTH(posts.post_date), DAY(posts.post_date), meta__' . $this->location_by . '_country.meta_value',52 'query_type' => 'get_results'53 ) );54 111 55 112 … … 57 114 $country_data = array(); 58 115 $export_data = array(); 59 foreach ( $location_query as $location_values ) { 60 61 if ( '' == $location_values->countries_data ) { 62 $location_values->countries_data = 'UNDEFINED'; 116 117 if ( 'number-orders' == $this->totals_by ) { 118 foreach ( $data->order_counts as $location_values ) { 119 if ( '' == $location_values->countries_data ) { 120 $location_values->countries_data = 'UNDEFINED'; 121 } 122 123 $country_data[$location_values->countries_data] = ( isset( $country_data[$location_values->countries_data] ) ) ? $location_values->count + $country_data[$location_values->countries_data] : $location_values->count; 124 125 if ( 'UNDEFINED' != $location_values->countries_data ) { 126 $export_data[$location_values->countries_data][] = $location_values; 127 } 63 128 } 64 65 if ( 'number-orders' == $this->totals_by ) { 66 $country_data[$location_values->countries_data] = ( isset( $country_data[$location_values->countries_data] ) ) ? $location_values->countries_data_count + $country_data[$location_values->countries_data] : $location_values->countries_data_count; 67 } elseif ( 'order-total' == $this->totals_by ) { 129 } elseif ( 'order-total' == $this->totals_by ) { 130 foreach ( $data->orders as $location_values ) { 131 132 if ( '' == $location_values->countries_data ) { 133 $location_values->countries_data = 'UNDEFINED'; 134 } 135 68 136 $country_data[$location_values->countries_data] = ( isset( $country_data[$location_values->countries_data] ) ) ? $location_values->total_sales + $country_data[$location_values->countries_data] : $location_values->total_sales; 137 138 if ( 'UNDEFINED' != $location_values->countries_data ) { 139 $export_data[$location_values->countries_data][] = $location_values; 140 } 69 141 } 70 71 if ( 'UNDEFINED' != $location_values->countries_data ) { 72 $export_data[$location_values->countries_data][] = $location_values; 73 } 74 } 142 } 143 75 144 76 145 //Pass the data to the screen. -
woocommerce-sales-by-location-report/trunk/woocommerce-location-report.php
r1065346 r1189764 6 6 * Author: Chuck Mac 7 7 * Author URI: http://www.chuckmac.info 8 * Version: 1. 18 * Version: 1.2 9 9 * Text Domain: wc_location_report 10 10 * Domain Path: /languages/ 11 11 * 12 * Copyright: (c) 2014 ChuckMac Development LLC12 * Copyright: (c) 2014-2015 ChuckMac Development LLC 13 13 * 14 14 * License: GNU General Public License v3.0 … … 18 18 * @author WooThemes 19 19 * @category Reports 20 * @copyright Copyright (c) 2014 , ChuckMac Development LLC20 * @copyright Copyright (c) 2014-2015, ChuckMac Development LLC 21 21 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 22 22 */ … … 45 45 46 46 /** plugin version number */ 47 public static $version = '1. 1';47 public static $version = '1.2'; 48 48 49 49 /** @var string the plugin file */ … … 95 95 //jVector includes - needs to be done in the footer so we can localize data as part of the report generation 96 96 wp_enqueue_script( 'jvectormap', plugins_url( '/lib/jquery-jvectormap-1.2.2.min.js', self::$plugin_file ), array( 'jquery' ), self::$version, true ); 97 wp_enqueue_script( 'jvectormap-world', plugins_url( '/lib/map-data/jquery-jvectormap-world-mill-en .js', self::$plugin_file ), array( 'jquery', 'jvectormap' ), self::$version, true );97 wp_enqueue_script( 'jvectormap-world', plugins_url( '/lib/map-data/jquery-jvectormap-world-mill-en', self::$plugin_file ), array( 'jquery', 'jvectormap' ), self::$version, true ); 98 98 99 99 //jVector css
Note: See TracChangeset
for help on using the changeset viewer.