@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | class wps_statistics_ctr { |
4 | 4 | |
@@ -6,14 +6,14 @@ discard block |
||
6 | 6 | |
7 | 7 | function __construct() { |
8 | 8 | // WP Main Actions |
9 | - add_action( 'admin_menu', array(&$this, 'register_stats_menu'), 250); |
|
10 | - add_action( 'save_post', array( &$this, 'wps_statistics_save_customer_infos') ); |
|
11 | - add_action( 'add_meta_boxes', array( &$this, 'add_customer_meta_box'), 1 ); |
|
9 | + add_action('admin_menu', array(&$this, 'register_stats_menu'), 250); |
|
10 | + add_action('save_post', array(&$this, 'wps_statistics_save_customer_infos')); |
|
11 | + add_action('add_meta_boxes', array(&$this, 'add_customer_meta_box'), 1); |
|
12 | 12 | |
13 | 13 | // Add Javascript Files & CSS File in admin |
14 | - add_action( 'admin_enqueue_scripts', array( $this, 'add_scripts' ) ); |
|
14 | + add_action('admin_enqueue_scripts', array($this, 'add_scripts')); |
|
15 | 15 | |
16 | - add_action( 'wp_ajax_wps_statistics_custom_date_view', array( $this, 'wps_statistics_custom_date_view' ) ); |
|
16 | + add_action('wp_ajax_wps_statistics_custom_date_view', array($this, 'wps_statistics_custom_date_view')); |
|
17 | 17 | |
18 | 18 | $this->wps_stats_mdl = new wps_statistics_mdl(); |
19 | 19 | } |
@@ -21,18 +21,18 @@ discard block |
||
21 | 21 | /** |
22 | 22 | * Add Javascript & CSS files |
23 | 23 | */ |
24 | - function add_scripts( $hook ) { |
|
24 | + function add_scripts($hook) { |
|
25 | 25 | global $current_screen; |
26 | - if( ! in_array( $current_screen->post_type, array( WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ), true ) && $hook != 'wpshop_shop_order_page_wpshop_statistics' ) |
|
26 | + if (!in_array($current_screen->post_type, array(WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS), true) && $hook != 'wpshop_shop_order_page_wpshop_statistics') |
|
27 | 27 | return; |
28 | 28 | |
29 | - wp_enqueue_script( 'wps_statistics_js_chart', WPSHOP_JS_URL . 'Chart.js' ); |
|
30 | - wp_enqueue_script( 'jquery' ); |
|
31 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
32 | - wp_enqueue_script( 'jquery-form' ); |
|
29 | + wp_enqueue_script('wps_statistics_js_chart', WPSHOP_JS_URL . 'Chart.js'); |
|
30 | + wp_enqueue_script('jquery'); |
|
31 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
32 | + wp_enqueue_script('jquery-form'); |
|
33 | 33 | |
34 | - wp_register_style( 'jquery-ui-wpsstats', '//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css', '', WPSHOP_VERSION ); |
|
35 | - wp_enqueue_style( 'jquery-ui-wpsstats' ); |
|
34 | + wp_register_style('jquery-ui-wpsstats', '//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css', '', WPSHOP_VERSION); |
|
35 | + wp_enqueue_style('jquery-ui-wpsstats'); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | function add_customer_meta_box() { |
42 | 42 | global $post; |
43 | - add_meta_box( 'wps_statistics_customer', __( 'Statistics', 'wps_price' ), array( &$this, 'wps_statistics_meta_box_content' ), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low' ); |
|
43 | + add_meta_box('wps_statistics_customer', __('Statistics', 'wps_price'), array(&$this, 'wps_statistics_meta_box_content'), WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS, 'side', 'low'); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -49,10 +49,10 @@ discard block |
||
49 | 49 | function wps_statistics_meta_box_content() { |
50 | 50 | global $post; |
51 | 51 | $user_meta = ''; |
52 | - if ( !empty($post) && !empty($post->post_author) ) { |
|
53 | - $user_meta = get_user_meta( $post->post_author, 'wps_statistics_exclude_customer', true ); |
|
52 | + if (!empty($post) && !empty($post->post_author)) { |
|
53 | + $user_meta = get_user_meta($post->post_author, 'wps_statistics_exclude_customer', true); |
|
54 | 54 | } |
55 | - $output = '<input type="checkbox" name="wps_statistics_exclude_customer" id="wps_statistics_exclude_customer" ' .( (!empty($user_meta) ) ? 'checked="checked"' : '' ). '/> <label for="wps_statistics_exclude_customer">' .__('Exclude this customer from WPShop Statistics', 'wpshop'). '</label>'; |
|
55 | + $output = '<input type="checkbox" name="wps_statistics_exclude_customer" id="wps_statistics_exclude_customer" ' . ((!empty($user_meta)) ? 'checked="checked"' : '') . '/> <label for="wps_statistics_exclude_customer">' . __('Exclude this customer from WPShop Statistics', 'wpshop') . '</label>'; |
|
56 | 56 | echo $output; |
57 | 57 | } |
58 | 58 | |
@@ -60,15 +60,15 @@ discard block |
||
60 | 60 | * Save action to exclude customer of statistics |
61 | 61 | */ |
62 | 62 | function wps_statistics_save_customer_infos() { |
63 | - $action = !empty( $_POST['action'] ) ? sanitize_text_field( $_POST['action'] ) : ''; |
|
64 | - $post_type = !empty( $_POST['post_type'] ) ? sanitize_text_field( $_POST['post_type'] ) : ''; |
|
65 | - $post_id = !empty( $_POST['post_ID'] ) ? (int) $_POST['post_ID'] : 0; |
|
66 | - $wps_statistics_exclude_customer = isset( $_POST['wps_statistics_exclude_customer'] ) ? (int) $_POST['wps_statistics_exclude_customer'] : 0; |
|
67 | - |
|
68 | - if ( !empty($action) && $action != 'autosave' && !empty($post_type) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS ) { |
|
69 | - $customer_def = get_post( $post_id ); |
|
70 | - if( isset( $wps_statistics_exclude_customer ) ) { |
|
71 | - update_user_meta( $customer_def->post_author, 'wps_statistics_exclude_customer', $wps_statistics_exclude_customer ); |
|
63 | + $action = !empty($_POST['action']) ? sanitize_text_field($_POST['action']) : ''; |
|
64 | + $post_type = !empty($_POST['post_type']) ? sanitize_text_field($_POST['post_type']) : ''; |
|
65 | + $post_id = !empty($_POST['post_ID']) ? (int)$_POST['post_ID'] : 0; |
|
66 | + $wps_statistics_exclude_customer = isset($_POST['wps_statistics_exclude_customer']) ? (int)$_POST['wps_statistics_exclude_customer'] : 0; |
|
67 | + |
|
68 | + if (!empty($action) && $action != 'autosave' && !empty($post_type) && $post_type == WPSHOP_NEWTYPE_IDENTIFIER_CUSTOMERS) { |
|
69 | + $customer_def = get_post($post_id); |
|
70 | + if (isset($wps_statistics_exclude_customer)) { |
|
71 | + update_user_meta($customer_def->post_author, 'wps_statistics_exclude_customer', $wps_statistics_exclude_customer); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | } |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | * Register statistics Menu |
78 | 78 | */ |
79 | 79 | function register_stats_menu() { |
80 | - add_submenu_page( 'edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER, __('Statistics', 'wpshop' ), __('Statistics', 'wpshop'), 'wpshop_view_statistics', 'wpshop_statistics', array($this, 'wps_display_statistics')); |
|
80 | + add_submenu_page('edit.php?post_type=' . WPSHOP_NEWTYPE_IDENTIFIER_ORDER, __('Statistics', 'wpshop'), __('Statistics', 'wpshop'), 'wpshop_view_statistics', 'wpshop_statistics', array($this, 'wps_display_statistics')); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | $main_stats_count = 5; |
90 | 90 | |
91 | 91 | $ordered_customers = array(); |
92 | - foreach ( $shop_orders as $order ) { |
|
92 | + foreach ($shop_orders as $order) { |
|
93 | 93 | $user_id = $order['order_postmeta']['customer_id']; |
94 | 94 | $customer_id = null; |
95 | 95 | $args = array( |
@@ -100,20 +100,20 @@ discard block |
||
100 | 100 | 'post_status' => 'all', |
101 | 101 | 'posts_per_page' => 1, |
102 | 102 | ); |
103 | - $customer = new WP_Query( $args ); |
|
103 | + $customer = new WP_Query($args); |
|
104 | 104 | |
105 | - if ( ! isset( $ordered_customers[ $user_id ]['count'] ) ) { |
|
106 | - $ordered_customers[ $user_id ]['count'] = 0; |
|
107 | - $ordered_customers[ $user_id ]['total_amount'] = 0; |
|
105 | + if (!isset($ordered_customers[$user_id]['count'])) { |
|
106 | + $ordered_customers[$user_id]['count'] = 0; |
|
107 | + $ordered_customers[$user_id]['total_amount'] = 0; |
|
108 | 108 | } |
109 | - $ordered_customers[ $user_id ]['count']++; |
|
110 | - $ordered_customers[ $user_id ]['id'] = $user_id; |
|
111 | - $ordered_customers[ $user_id ]['post_id'] = $customer->post->ID; |
|
112 | - $ordered_customers[ $user_id ]['name'] = ( !empty($order['order_info']) && !empty($order['order_info']['billing']) && !empty($order['order_info']['billing']['address']) && !empty($order['order_info']['billing']['address']['address_last_name']) && !empty($order['order_info']['billing']['address']['address_first_name']) ) ? $order['order_info']['billing']['address']['address_first_name'].' '.$order['order_info']['billing']['address']['address_last_name'] : '';; |
|
113 | - $ordered_customers[ $user_id ]['total_amount'] += $order['order_postmeta']['order_grand_total']; |
|
109 | + $ordered_customers[$user_id]['count']++; |
|
110 | + $ordered_customers[$user_id]['id'] = $user_id; |
|
111 | + $ordered_customers[$user_id]['post_id'] = $customer->post->ID; |
|
112 | + $ordered_customers[$user_id]['name'] = (!empty($order['order_info']) && !empty($order['order_info']['billing']) && !empty($order['order_info']['billing']['address']) && !empty($order['order_info']['billing']['address']['address_last_name']) && !empty($order['order_info']['billing']['address']['address_first_name'])) ? $order['order_info']['billing']['address']['address_first_name'] . ' ' . $order['order_info']['billing']['address']['address_last_name'] : ''; ; |
|
113 | + $ordered_customers[$user_id]['total_amount'] += $order['order_postmeta']['order_grand_total']; |
|
114 | 114 | } |
115 | 115 | |
116 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps-statistics") ); |
|
116 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, "backend", "wps-statistics")); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -123,13 +123,13 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return [type] [description] |
125 | 125 | */ |
126 | - function get_average_time_between_orders( $order_list ) { |
|
126 | + function get_average_time_between_orders($order_list) { |
|
127 | 127 | $time_between_orders = 0; |
128 | 128 | $last_date = null; |
129 | - foreach ( $order_list as $order ) { |
|
130 | - if ( null !== $last_date ) { |
|
131 | - $last_order = new DateTime( $last_date ); |
|
132 | - $current_order = new DateTime( $order['order_postmeta']['order_date'] ); |
|
129 | + foreach ($order_list as $order) { |
|
130 | + if (null !== $last_date) { |
|
131 | + $last_order = new DateTime($last_date); |
|
132 | + $current_order = new DateTime($order['order_postmeta']['order_date']); |
|
133 | 133 | $time_between_orders += $last_order->getTimestamp() - $current_order->getTimestamp(); |
134 | 134 | } else { |
135 | 135 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $last_date = $order['order_postmeta']['order_date']; |
139 | 139 | } |
140 | 140 | |
141 | - return round( $time_between_orders / count( $order_list ) ); |
|
141 | + return round($time_between_orders / count($order_list)); |
|
142 | 142 | } |
143 | 143 | |
144 | 144 | /** |
@@ -146,27 +146,27 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return boolean The boolean state allowing to know if the shop is out of bounds for time since last order |
148 | 148 | */ |
149 | - function check_current_time_since_last_order( $list_orders ) { |
|
149 | + function check_current_time_since_last_order($list_orders) { |
|
150 | 150 | $average_check = array( |
151 | 151 | 'status' => false, |
152 | 152 | 'last_date' => null, |
153 | 153 | 'average' => null, |
154 | 154 | 'duration' => null, |
155 | 155 | ); |
156 | - $current_date = new DateTime( current_time( 'Y-m-d H:i:s', 0 ) ); |
|
156 | + $current_date = new DateTime(current_time('Y-m-d H:i:s', 0)); |
|
157 | 157 | |
158 | - if ( ! empty( $list_orders ) ) { |
|
159 | - $last_order = array_slice( $list_orders, 0, 1 ); |
|
160 | - foreach ( $last_order as $order ) { |
|
158 | + if (!empty($list_orders)) { |
|
159 | + $last_order = array_slice($list_orders, 0, 1); |
|
160 | + foreach ($last_order as $order) { |
|
161 | 161 | $average_check['last_date'] = $order['order_postmeta']['order_date']; |
162 | 162 | } |
163 | - $last_order_dateTime = new DateTime( $average_check['last_date'] ); |
|
163 | + $last_order_dateTime = new DateTime($average_check['last_date']); |
|
164 | 164 | |
165 | 165 | $duration_since_last_order = $current_date->getTimestamp() - $last_order_dateTime->getTimestamp(); |
166 | 166 | $average_check['duration'] = $duration_since_last_order; |
167 | - $average_check['average'] = $this->get_average_time_between_orders( $list_orders ); |
|
167 | + $average_check['average'] = $this->get_average_time_between_orders($list_orders); |
|
168 | 168 | |
169 | - $average_check['status'] = ( $average_check['duration'] > $average_check['average'] ? true : false ); |
|
169 | + $average_check['status'] = ($average_check['duration'] > $average_check['average'] ? true : false); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | return $average_check; |
@@ -175,43 +175,43 @@ discard block |
||
175 | 175 | /** |
176 | 176 | * Main Statistics output |
177 | 177 | */ |
178 | - function wps_display_main_statistics( $shop_orders = null ) { |
|
178 | + function wps_display_main_statistics($shop_orders = null) { |
|
179 | 179 | global $current_month_offset; |
180 | 180 | |
181 | - if ( null === $shop_orders ) { |
|
181 | + if (null === $shop_orders) { |
|
182 | 182 | $shop_orders = $this->wps_stats_mdl->wps_orders_all(); |
183 | 183 | } |
184 | 184 | |
185 | - $current_month_offset = (int) current_time( 'm' ); |
|
186 | - $current_month_offset = isset( $_GET['month'] ) ? (int) $_GET['month'] : $current_month_offset; |
|
185 | + $current_month_offset = (int)current_time('m'); |
|
186 | + $current_month_offset = isset($_GET['month']) ? (int)$_GET['month'] : $current_month_offset; |
|
187 | 187 | |
188 | - $current_month_start = date( 'Y-m-d 00:00:00', strtotime( 'first day of this month', time() ) ); |
|
189 | - $current_month_end = date( 'Y-m-d 23:59:59', strtotime( 'last day of this month', time() ) ); |
|
188 | + $current_month_start = date('Y-m-d 00:00:00', strtotime('first day of this month', time())); |
|
189 | + $current_month_end = date('Y-m-d 23:59:59', strtotime('last day of this month', time())); |
|
190 | 190 | |
191 | - $last_month_start = date( 'Y-m-d 00:00:00', strtotime( 'first day of last month', time() ) ); |
|
192 | - $last_month_end = date( 'Y-m-d 23:59:59', strtotime( 'last day of last month', time() ) ); |
|
193 | - $one_month_ago = date( 'Y-m-d 23:59:59', strtotime( '-1 month', time() ) ); |
|
191 | + $last_month_start = date('Y-m-d 00:00:00', strtotime('first day of last month', time())); |
|
192 | + $last_month_end = date('Y-m-d 23:59:59', strtotime('last day of last month', time())); |
|
193 | + $one_month_ago = date('Y-m-d 23:59:59', strtotime('-1 month', time())); |
|
194 | 194 | |
195 | 195 | $dates = array( |
196 | - __( 'Current month', 'wpshop' ) => array( |
|
196 | + __('Current month', 'wpshop') => array( |
|
197 | 197 | 'after' => $current_month_start, |
198 | 198 | 'before' => $current_month_end, |
199 | 199 | 'inclusive' => true, |
200 | 200 | ), |
201 | - sprintf( __( 'One month ago (%s)', 'wpshop' ), mysql2date( get_option( 'date_format' ), $one_month_ago, true ) ) => array( |
|
201 | + sprintf(__('One month ago (%s)', 'wpshop'), mysql2date(get_option('date_format'), $one_month_ago, true)) => array( |
|
202 | 202 | 'after' => $last_month_start, |
203 | 203 | 'before' => $one_month_ago, |
204 | 204 | 'inclusive' => true, |
205 | 205 | ), |
206 | - __( 'Last month', 'wpshop' ) => array( |
|
206 | + __('Last month', 'wpshop') => array( |
|
207 | 207 | 'after' => $last_month_start, |
208 | 208 | 'before' => $last_month_end, |
209 | 209 | 'inclusive' => true, |
210 | 210 | ), |
211 | - __( 'From the beginning', 'wpshop' ) => null, |
|
211 | + __('From the beginning', 'wpshop') => null, |
|
212 | 212 | ); |
213 | 213 | |
214 | - require_once( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_main' ) ); |
|
214 | + require_once(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_main')); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
@@ -221,42 +221,42 @@ discard block |
||
221 | 221 | * @param string $start Optionnal. The start date to get stats for. |
222 | 222 | * @param string $end Optionnal. The end date to get stats for. |
223 | 223 | */ |
224 | - function wps_display_custom_statistics( $shop_orders, $start = null, $end = null ) { |
|
225 | - $current_month_start = date( 'Y-m-d', strtotime( 'first day of this month', time() ) ); |
|
226 | - $current_month_end = date( 'Y-m-d', strtotime( 'last day of this month', time() ) ); |
|
224 | + function wps_display_custom_statistics($shop_orders, $start = null, $end = null) { |
|
225 | + $current_month_start = date('Y-m-d', strtotime('first day of this month', time())); |
|
226 | + $current_month_end = date('Y-m-d', strtotime('last day of this month', time())); |
|
227 | 227 | |
228 | - $last_month_start = date( 'Y-m-d', strtotime( 'first day of last month', time() ) ); |
|
229 | - $last_month_end = date( 'Y-m-d', strtotime( 'last day of last month', time() ) ); |
|
228 | + $last_month_start = date('Y-m-d', strtotime('first day of last month', time())); |
|
229 | + $last_month_end = date('Y-m-d', strtotime('last day of last month', time())); |
|
230 | 230 | |
231 | 231 | $date_start = null !== $start ? $start : $current_month_start; |
232 | 232 | $date_end = null !== $end ? $end : $current_month_end; |
233 | 233 | |
234 | 234 | $stats_translations = array( |
235 | - 'numberOfSales' => __( 'Number of sales', 'wpshop' ), |
|
236 | - 'sales' => __( 'sales', 'wpshop' ), |
|
237 | - 'salesAmount' => __( 'Sales amount', 'wpshop' ), |
|
235 | + 'numberOfSales' => __('Number of sales', 'wpshop'), |
|
236 | + 'sales' => __('sales', 'wpshop'), |
|
237 | + 'salesAmount' => __('Sales amount', 'wpshop'), |
|
238 | 238 | 'wpshopCurrency' => wpshop_tools::wpshop_get_currency(), |
239 | 239 | ); |
240 | 240 | |
241 | 241 | $orders_total_amount = $orders_total_shipping_cost = $order_count = 0; |
242 | 242 | $orders_number_stats = $orders_amount_stats = array(); |
243 | - if ( ! empty( $shop_orders ) ) { |
|
244 | - foreach ( $shop_orders as $order ) { |
|
243 | + if (!empty($shop_orders)) { |
|
244 | + foreach ($shop_orders as $order) { |
|
245 | 245 | $order_data = $order['order_postmeta']; |
246 | - if ( ( $date_start <= $order_data['order_date'] ) && ( $date_end >= $order_data['order_date'] ) ) { |
|
246 | + if (($date_start <= $order_data['order_date']) && ($date_end >= $order_data['order_date'])) { |
|
247 | 247 | $orders_total_amount += $order_data['order_grand_total']; |
248 | 248 | $order_count++; |
249 | 249 | |
250 | - $time = strtotime( date( 'Ymd', strtotime( $order_data['order_date'] ) ) ) . '000'; |
|
251 | - if ( ! isset( $orders_number_stats[ $time ] ) ) { |
|
252 | - $orders_number_stats[ $time ] = 0; |
|
250 | + $time = strtotime(date('Ymd', strtotime($order_data['order_date']))) . '000'; |
|
251 | + if (!isset($orders_number_stats[$time])) { |
|
252 | + $orders_number_stats[$time] = 0; |
|
253 | 253 | } |
254 | - $orders_number_stats[ $time ]++; |
|
254 | + $orders_number_stats[$time]++; |
|
255 | 255 | |
256 | - if ( ! isset( $orders_amount_stats[ $time ] ) ) { |
|
257 | - $orders_amount_stats[ $time ] = 0; |
|
256 | + if (!isset($orders_amount_stats[$time])) { |
|
257 | + $orders_amount_stats[$time] = 0; |
|
258 | 258 | } |
259 | - $orders_amount_stats[ $time ] += $order_data['order_grand_total']; |
|
259 | + $orders_amount_stats[$time] += $order_data['order_grand_total']; |
|
260 | 260 | |
261 | 261 | $orders_total_shipping_cost += $order_data['order_shipping_cost']; |
262 | 262 | } |
@@ -264,24 +264,24 @@ discard block |
||
264 | 264 | } |
265 | 265 | |
266 | 266 | $orders_number_for_stats = null; |
267 | - if ( ! empty( $orders_number_stats ) ) { |
|
267 | + if (!empty($orders_number_stats)) { |
|
268 | 268 | $orders_numbers = array(); |
269 | - foreach ( $orders_number_stats as $time => $number ) { |
|
269 | + foreach ($orders_number_stats as $time => $number) { |
|
270 | 270 | $orders_numbers[] = "[$time, $number]"; |
271 | 271 | } |
272 | - $orders_number_for_stats = implode( ',', $orders_numbers ); |
|
272 | + $orders_number_for_stats = implode(',', $orders_numbers); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | $orders_amount_for_stats = null; |
276 | - if ( ! empty( $orders_amount_stats ) ) { |
|
276 | + if (!empty($orders_amount_stats)) { |
|
277 | 277 | $orders_amounts = array(); |
278 | - foreach ( $orders_amount_stats as $time => $amount ) { |
|
278 | + foreach ($orders_amount_stats as $time => $amount) { |
|
279 | 279 | $orders_amounts[] = "[$time, $amount]"; |
280 | 280 | } |
281 | - $orders_amount_for_stats = implode( ',', $orders_amounts ); |
|
281 | + $orders_amount_for_stats = implode(',', $orders_amounts); |
|
282 | 282 | } |
283 | 283 | |
284 | - $user_subscription_number = new WP_User_Query( array( |
|
284 | + $user_subscription_number = new WP_User_Query(array( |
|
285 | 285 | 'date_query' => array( |
286 | 286 | array( |
287 | 287 | 'after' => $date_start, |
@@ -290,21 +290,21 @@ discard block |
||
290 | 290 | ), |
291 | 291 | ), |
292 | 292 | 'count_total' => true, |
293 | - ) ); |
|
293 | + )); |
|
294 | 294 | |
295 | - require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_custom' ) ); |
|
295 | + require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_custom')); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
299 | 299 | * Ajax callback - Display custom statistics for given date |
300 | 300 | */ |
301 | 301 | function wps_statistics_custom_date_view() { |
302 | - check_ajax_referer( 'wps_statistics_custom_date_view' ); |
|
302 | + check_ajax_referer('wps_statistics_custom_date_view'); |
|
303 | 303 | |
304 | - $start_date = ! empty( $_POST ) && ! empty( $_POST['wps_statistics_start_date'] ) ? sanitize_text_field( $_POST['wps_statistics_start_date'] ) : date( 'Y-m-d', strtotime( 'first day of this month', time() ) ); |
|
305 | - $end_date = ! empty( $_POST ) && ! empty( $_POST['wps_statistics_end_date'] ) ? sanitize_text_field( $_POST['wps_statistics_end_date'] ) : date( 'Y-m-d', strtotime( 'last day of this month', time() ) ); |
|
304 | + $start_date = !empty($_POST) && !empty($_POST['wps_statistics_start_date']) ? sanitize_text_field($_POST['wps_statistics_start_date']) : date('Y-m-d', strtotime('first day of this month', time())); |
|
305 | + $end_date = !empty($_POST) && !empty($_POST['wps_statistics_end_date']) ? sanitize_text_field($_POST['wps_statistics_end_date']) : date('Y-m-d', strtotime('last day of this month', time())); |
|
306 | 306 | |
307 | - $order_list = $this->wps_stats_mdl->wps_orders_all( array( |
|
307 | + $order_list = $this->wps_stats_mdl->wps_orders_all(array( |
|
308 | 308 | 'date_query' => array( |
309 | 309 | array( |
310 | 310 | 'after' => $date_start, |
@@ -312,13 +312,13 @@ discard block |
||
312 | 312 | 'inclusive' => true, |
313 | 313 | ), |
314 | 314 | ), |
315 | - ) ); |
|
315 | + )); |
|
316 | 316 | |
317 | 317 | ob_start(); |
318 | - $this->wps_display_custom_statistics( $order_list, $start_date, $end_date ); |
|
318 | + $this->wps_display_custom_statistics($order_list, $start_date, $end_date); |
|
319 | 319 | $output = ob_get_clean(); |
320 | 320 | |
321 | - wp_die( $output ); |
|
321 | + wp_die($output); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | } |
@@ -1,28 +1,28 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | ?> |
3 | 3 | <div class="wrap wps_statistics"> |
4 | - <h2><span class="dashicons dashicons-chart-area" style="font-size : 30px; width : 30px; height : 30px"></span> <?php _e( 'WPShop Statistics', 'wpshop' )?></h2> |
|
4 | + <h2><span class="dashicons dashicons-chart-area" style="font-size : 30px; width : 30px; height : 30px"></span> <?php _e('WPShop Statistics', 'wpshop')?></h2> |
|
5 | 5 | |
6 | 6 | <div class="wps-boxed"> |
7 | 7 | <div class="wps-gridwrapper2-padded"> |
8 | 8 | <div> |
9 | 9 | <div> |
10 | 10 | <div> |
11 | - <span class="wps-h5"><?php _e( 'Sales statistics', 'wpshop'); ?></span> |
|
12 | - <?php $this->wps_display_main_statistics( $shop_orders ); ?> |
|
11 | + <span class="wps-h5"><?php _e('Sales statistics', 'wpshop'); ?></span> |
|
12 | + <?php $this->wps_display_main_statistics($shop_orders); ?> |
|
13 | 13 | </div> |
14 | 14 | </div> |
15 | 15 | <div> |
16 | 16 | <div> |
17 | - <span class="wps-h5"><?php _e( 'Orders infos', 'wpshop'); ?></span> |
|
18 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_average') ); ?> |
|
17 | + <span class="wps-h5"><?php _e('Orders infos', 'wpshop'); ?></span> |
|
18 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_average')); ?> |
|
19 | 19 | </div> |
20 | 20 | </div> |
21 | 21 | </div> |
22 | 22 | <div> |
23 | 23 | <div> |
24 | - <span class="wps-h5"><?php _e( 'Custom statistics', 'wpshop'); ?></span> |
|
25 | - <div id="wps_statistics_custom_container" class="wps-bloc-loader" ><?php $this->wps_display_custom_statistics( $shop_orders ); ?></div> |
|
24 | + <span class="wps-h5"><?php _e('Custom statistics', 'wpshop'); ?></span> |
|
25 | + <div id="wps_statistics_custom_container" class="wps-bloc-loader" ><?php $this->wps_display_custom_statistics($shop_orders); ?></div> |
|
26 | 26 | </div> |
27 | 27 | </div> |
28 | 28 | </div> |
@@ -31,26 +31,26 @@ discard block |
||
31 | 31 | <div class="wps-boxed"> |
32 | 32 | <div class="wps-gridwrapper3-padded"> |
33 | 33 | <div> |
34 | - <span class="wps-h5"><?php _e( 'Last orders', 'wpshop'); ?></span> |
|
35 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_last_orders') ); ?> |
|
34 | + <span class="wps-h5"><?php _e('Last orders', 'wpshop'); ?></span> |
|
35 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_last_orders')); ?> |
|
36 | 36 | </div> |
37 | 37 | <div> |
38 | - <span class="wps-h5"><?php _e( 'Most buyed products', 'wpshop'); ?></span> |
|
39 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_sales') ); ?> |
|
38 | + <span class="wps-h5"><?php _e('Most buyed products', 'wpshop'); ?></span> |
|
39 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_sales')); ?> |
|
40 | 40 | </div> |
41 | 41 | <div> |
42 | - <span class="wps-h5"><?php _e( 'Most viewed products', 'wpshop'); ?></span> |
|
43 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_most_viewed_products') ); ?> |
|
42 | + <span class="wps-h5"><?php _e('Most viewed products', 'wpshop'); ?></span> |
|
43 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_most_viewed_products')); ?> |
|
44 | 44 | </div> |
45 | 45 | </div> |
46 | 46 | <div class="wps-gridwrapper3-padded"> |
47 | 47 | <div> |
48 | - <span class="wps-h5"><?php _e( 'Best customers per amount', 'wpshop'); ?></span> |
|
49 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_customers_amount') ); ?> |
|
48 | + <span class="wps-h5"><?php _e('Best customers per amount', 'wpshop'); ?></span> |
|
49 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_customers_amount')); ?> |
|
50 | 50 | </div> |
51 | 51 | <div> |
52 | - <span class="wps-h5"><?php _e( 'Best customers per count', 'wpshop'); ?></span> |
|
53 | - <?php require( wpshop_tools::get_template_part( WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_customers_count') ); ?> |
|
52 | + <span class="wps-h5"><?php _e('Best customers per count', 'wpshop'); ?></span> |
|
53 | + <?php require(wpshop_tools::get_template_part(WPS_STATISTICS_DIR, WPS_STATISTICS_TEMPLATES_MAIN_DIR, 'backend', 'wps_statistics_best_customers_count')); ?> |
|
54 | 54 | </div> |
55 | 55 | </div> |
56 | 56 | </div> |
@@ -2,27 +2,27 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Display statistics for custom date |
4 | 4 | */ |
5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
5 | +if (!defined('ABSPATH')) { |
|
6 | 6 | exit; |
7 | 7 | } |
8 | 8 | |
9 | 9 | ?> |
10 | 10 | <div class="wps-table" style="margin: 0px;" > |
11 | 11 | <div class="wps-table-row"> |
12 | - <div class="wps-table-cell"><a class="wps-statistics-quick-links" href="#" data-from="<?php echo $last_month_start; ?>" data-to="<?php echo $last_month_end; ?>" ><?php esc_html_e( 'Last month', 'wpshop' ); ?></a></div> |
|
13 | - <div class="wps-table-cell"><a class="wps-statistics-quick-links" href="#" data-from="<?php echo $current_month_start; ?>" data-to="<?php echo $current_month_end; ?>" ><?php esc_html_e( 'Current month', 'wpshop' ); ?></a></div> |
|
14 | - <div class="wps-table-cell"><a class="wps-statistics-quick-links" href="#" data-from="<?php echo current_time( 'Y-m-d' ); ?>" data-to="<?php echo current_time( 'Y-m-d' ); ?>" ><?php esc_html_e( 'Today', 'wpshop' ); ?></a></div> |
|
12 | + <div class="wps-table-cell"><a class="wps-statistics-quick-links" href="#" data-from="<?php echo $last_month_start; ?>" data-to="<?php echo $last_month_end; ?>" ><?php esc_html_e('Last month', 'wpshop'); ?></a></div> |
|
13 | + <div class="wps-table-cell"><a class="wps-statistics-quick-links" href="#" data-from="<?php echo $current_month_start; ?>" data-to="<?php echo $current_month_end; ?>" ><?php esc_html_e('Current month', 'wpshop'); ?></a></div> |
|
14 | + <div class="wps-table-cell"><a class="wps-statistics-quick-links" href="#" data-from="<?php echo current_time('Y-m-d'); ?>" data-to="<?php echo current_time('Y-m-d'); ?>" ><?php esc_html_e('Today', 'wpshop'); ?></a></div> |
|
15 | 15 | </div> |
16 | 16 | </div> |
17 | 17 | <center> |
18 | - <form action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="wps_statistics_date_customizer" method="post" > |
|
18 | + <form action="<?php echo admin_url('admin-ajax.php'); ?>" id="wps_statistics_date_customizer" method="post" > |
|
19 | 19 | <input type="hidden" name="action" value="wps_statistics_custom_date_view" /> |
20 | - <?php wp_nonce_field( 'wps_statistics_custom_date_view' ); ?> |
|
21 | - <?php esc_html_e( 'Begin date', 'wpshop' ); ?> |
|
22 | - <input type="text" name="wps_statistics_start_date" class="wps_statistics_date" value="<?php echo esc_attr( $date_start ); ?>" /> |
|
23 | - <?php esc_html_e( 'End date', 'wpshop' ); ?> |
|
24 | - <input type="text" name="wps_statistics_end_date" class="wps_statistics_date" value="<?php echo esc_attr( $date_end ); ?>" /> |
|
25 | - <button class="button button-primary" ><?php esc_html_e( 'View', 'wpshop' ); ?></button> |
|
20 | + <?php wp_nonce_field('wps_statistics_custom_date_view'); ?> |
|
21 | + <?php esc_html_e('Begin date', 'wpshop'); ?> |
|
22 | + <input type="text" name="wps_statistics_start_date" class="wps_statistics_date" value="<?php echo esc_attr($date_start); ?>" /> |
|
23 | + <?php esc_html_e('End date', 'wpshop'); ?> |
|
24 | + <input type="text" name="wps_statistics_end_date" class="wps_statistics_date" value="<?php echo esc_attr($date_end); ?>" /> |
|
25 | + <button class="button button-primary" ><?php esc_html_e('View', 'wpshop'); ?></button> |
|
26 | 26 | </form> |
27 | 27 | </center> |
28 | 28 | |
@@ -30,26 +30,26 @@ discard block |
||
30 | 30 | |
31 | 31 | <div class="wps-table"> |
32 | 32 | <div class="wps-table-header wps-table-row"> |
33 | - <div class="wps-table-cell"><?php esc_html_e( 'Order count', 'wpshop' ); ?></div> |
|
34 | - <div class="wps-table-cell"><?php esc_html_e( 'Order total amount', 'wpshop' ); ?></div> |
|
35 | - <div class="wps-table-cell"><?php esc_html_e( 'Shipping amount', 'wpshop' ); ?></div> |
|
36 | - <div class="wps-table-cell"><?php esc_html_e( 'Customer subscription', 'wpshop' ); ?></div> |
|
33 | + <div class="wps-table-cell"><?php esc_html_e('Order count', 'wpshop'); ?></div> |
|
34 | + <div class="wps-table-cell"><?php esc_html_e('Order total amount', 'wpshop'); ?></div> |
|
35 | + <div class="wps-table-cell"><?php esc_html_e('Shipping amount', 'wpshop'); ?></div> |
|
36 | + <div class="wps-table-cell"><?php esc_html_e('Customer subscription', 'wpshop'); ?></div> |
|
37 | 37 | </div> |
38 | 38 | <div class="wps-table-row"> |
39 | - <?php if ( 0 !== $order_count ) : ?> |
|
40 | - <div class="wps-table-cell"><?php echo esc_html( $order_count ); ?></div> |
|
41 | - <div class="wps-table-cell"><?php echo esc_html( number_format( $orders_total_amount, 2, '.', '' ) . ' ' . wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
|
42 | - <div class="wps-table-cell"><?php echo esc_html( number_format( $orders_total_shipping_cost, 2, '.', '' ) . ' ' . wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
|
39 | + <?php if (0 !== $order_count) : ?> |
|
40 | + <div class="wps-table-cell"><?php echo esc_html($order_count); ?></div> |
|
41 | + <div class="wps-table-cell"><?php echo esc_html(number_format($orders_total_amount, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false)); ?></div> |
|
42 | + <div class="wps-table-cell"><?php echo esc_html(number_format($orders_total_shipping_cost, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false)); ?></div> |
|
43 | 43 | <?php else : ?> |
44 | - <div class="wps-table-cell"><?php esc_html_e( 'No orders have been placed for the moment', 'wpshop' ); ?></div> |
|
44 | + <div class="wps-table-cell"><?php esc_html_e('No orders have been placed for the moment', 'wpshop'); ?></div> |
|
45 | 45 | <div class="wps-table-cell"> </div> |
46 | 46 | <div class="wps-table-cell"> </div> |
47 | 47 | <?php endif; ?> |
48 | - <div class="wps-table-cell"><?php echo esc_html( $user_subscription_number->get_total() ); ?></div> |
|
48 | + <div class="wps-table-cell"><?php echo esc_html($user_subscription_number->get_total()); ?></div> |
|
49 | 49 | </div> |
50 | 50 | </div> |
51 | 51 | <script type="text/javascript">/* <![CDATA[ */ |
52 | - var wpsStats = <?php echo json_encode( $stats_translations ); ?>; |
|
52 | + var wpsStats = <?php echo json_encode($stats_translations); ?>; |
|
53 | 53 | |
54 | 54 | var numberOfSales = [<?php echo $orders_number_for_stats; ?>]; |
55 | 55 | for (var i = 0; i < numberOfSales.length; ++i) numberOfSales[i][0] += 60 * 60 * 1000; |
@@ -40,8 +40,11 @@ |
||
40 | 40 | <div class="wps-table-cell"><?php echo esc_html( $order_count ); ?></div> |
41 | 41 | <div class="wps-table-cell"><?php echo esc_html( number_format( $orders_total_amount, 2, '.', '' ) . ' ' . wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
42 | 42 | <div class="wps-table-cell"><?php echo esc_html( number_format( $orders_total_shipping_cost, 2, '.', '' ) . ' ' . wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
43 | - <?php else : ?> |
|
44 | - <div class="wps-table-cell"><?php esc_html_e( 'No orders have been placed for the moment', 'wpshop' ); ?></div> |
|
43 | + <?php else { |
|
44 | + : ?> |
|
45 | + <div class="wps-table-cell"><?php esc_html_e( 'No orders have been placed for the moment', 'wpshop' ); |
|
46 | +} |
|
47 | +?></div> |
|
45 | 48 | <div class="wps-table-cell"> </div> |
46 | 49 | <div class="wps-table-cell"> </div> |
47 | 50 | <?php endif; ?> |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Display the last order list |
4 | 4 | */ |
5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
5 | +if (!defined('ABSPATH')) { |
|
6 | 6 | exit; |
7 | 7 | } |
8 | 8 | |
@@ -23,54 +23,54 @@ discard block |
||
23 | 23 | ); |
24 | 24 | $i = 0; |
25 | 25 | $product_numbers = 0; |
26 | -foreach ( $shop_orders as $order ) { |
|
26 | +foreach ($shop_orders as $order) { |
|
27 | 27 | $order_amounts['sum'] += $order['order_postmeta']['order_grand_total']; |
28 | 28 | |
29 | 29 | /** Count how many products in each order */ |
30 | - $product_numbers += count( $order['order_postmeta']['order_items'] ); |
|
30 | + $product_numbers += count($order['order_postmeta']['order_items']); |
|
31 | 31 | |
32 | - if ( ( 0 === $i ) || ( ( 0 != $order['order_postmeta']['order_grand_total'] ) && ( $order['order_postmeta']['order_grand_total'] < $order_amounts['min']['count'] ) ) ) { |
|
32 | + if ((0 === $i) || ((0 != $order['order_postmeta']['order_grand_total']) && ($order['order_postmeta']['order_grand_total'] < $order_amounts['min']['count']))) { |
|
33 | 33 | $order_amounts['min']['count'] = $order['order_postmeta']['order_grand_total']; |
34 | 34 | $order_amounts['min']['id'] = $order['post']->ID; |
35 | 35 | } |
36 | - if ( $order['order_postmeta']['order_grand_total'] > $order_amounts['max']['count'] ) { |
|
36 | + if ($order['order_postmeta']['order_grand_total'] > $order_amounts['max']['count']) { |
|
37 | 37 | $order_amounts['max']['count'] = $order['order_postmeta']['order_grand_total']; |
38 | 38 | $order_amounts['max']['id'] = $order['post']->ID; |
39 | 39 | } |
40 | 40 | $i++; |
41 | 41 | } |
42 | -$order_amounts['average'] = $order_amounts['sum'] / count( $shop_orders ); |
|
43 | -$product_average = round( $product_numbers / count( $shop_orders ) ); |
|
42 | +$order_amounts['average'] = $order_amounts['sum'] / count($shop_orders); |
|
43 | +$product_average = round($product_numbers / count($shop_orders)); |
|
44 | 44 | |
45 | 45 | /** |
46 | 46 | * Average time between orders |
47 | 47 | */ |
48 | -$average_in_minutes = ( $this->get_average_time_between_orders( $shop_orders ) / 60 ); |
|
48 | +$average_in_minutes = ($this->get_average_time_between_orders($shop_orders) / 60); |
|
49 | 49 | $format = '%hh %imin'; |
50 | -if ( 1440 <= $average_in_minutes ) { |
|
50 | +if (1440 <= $average_in_minutes) { |
|
51 | 51 | $format = '%aj ' . $format; |
52 | 52 | } |
53 | -$human_readable_time = wpshop_tools::minutes_to_time( $average_in_minutes, $format ); |
|
53 | +$human_readable_time = wpshop_tools::minutes_to_time($average_in_minutes, $format); |
|
54 | 54 | |
55 | 55 | ?> |
56 | 56 | <div class="wps-table"> |
57 | 57 | <div class="wps-table-row"> |
58 | - <div class="wps-table-cell textleft" ><?php esc_html_e( 'Orders average amount', 'wpshop' ); ?></div> |
|
59 | - <div class="wps-table-cell textleft" ><?php echo esc_html( number_format( $order_amounts['average'], 2, '.', '' ).' '.wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
|
58 | + <div class="wps-table-cell textleft" ><?php esc_html_e('Orders average amount', 'wpshop'); ?></div> |
|
59 | + <div class="wps-table-cell textleft" ><?php echo esc_html(number_format($order_amounts['average'], 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false)); ?></div> |
|
60 | 60 | </div> |
61 | 61 | <div class="wps-table-row"> |
62 | - <div class="wps-table-cell textleft" ><?php esc_html_e( 'Average time between orders', 'wpshop' ); ?></div> |
|
62 | + <div class="wps-table-cell textleft" ><?php esc_html_e('Average time between orders', 'wpshop'); ?></div> |
|
63 | 63 | <div class="wps-table-cell textleft" > |
64 | - <?php echo esc_html( $human_readable_time ); ?> |
|
64 | + <?php echo esc_html($human_readable_time); ?> |
|
65 | 65 | <?php |
66 | - $order_duration_state = $this->check_current_time_since_last_order( $shop_orders ); |
|
67 | - $duration = ( $order_duration_state['duration'] / 60 ); |
|
66 | + $order_duration_state = $this->check_current_time_since_last_order($shop_orders); |
|
67 | + $duration = ($order_duration_state['duration'] / 60); |
|
68 | 68 | $format = '%hh %imin'; |
69 | - if ( 1440 <= $duration ) { |
|
69 | + if (1440 <= $duration) { |
|
70 | 70 | $format = '%aj ' . $format; |
71 | 71 | } |
72 | - $time_since_last_order = wpshop_tools::minutes_to_time( $duration, $format ); |
|
73 | - if ( true === $order_duration_state['status'] ) : |
|
72 | + $time_since_last_order = wpshop_tools::minutes_to_time($duration, $format); |
|
73 | + if (true === $order_duration_state['status']) : |
|
74 | 74 | $text_color = 'red'; |
75 | 75 | $icon = 'dashicons-warning'; |
76 | 76 | else: |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | $icon = 'dashicons-yes'; |
79 | 79 | endif; |
80 | 80 | ?> |
81 | - <br/><span style="color: <?php echo $text_color; ?>;" ><i class="dashicons <?php echo $icon; ?>"></i><?php echo esc_html( sprintf( __( 'Last order date %1$s - Time since: %2$s', 'wpshop' ), mysql2date( get_option( 'date_format' ), $order_duration_state['last_date'], true ), $time_since_last_order ) ); ?></span> |
|
81 | + <br/><span style="color: <?php echo $text_color; ?>;" ><i class="dashicons <?php echo $icon; ?>"></i><?php echo esc_html(sprintf(__('Last order date %1$s - Time since: %2$s', 'wpshop'), mysql2date(get_option('date_format'), $order_duration_state['last_date'], true), $time_since_last_order)); ?></span> |
|
82 | 82 | </div> |
83 | 83 | </div> |
84 | 84 | <div class="wps-table-row"> |
85 | - <div class="wps-table-cell textleft" ><?php esc_html_e( 'Average product number into an order', 'wpshop' ); ?></div> |
|
86 | - <div class="wps-table-cell textleft" ><?php echo esc_html( $product_average ); ?></div> |
|
85 | + <div class="wps-table-cell textleft" ><?php esc_html_e('Average product number into an order', 'wpshop'); ?></div> |
|
86 | + <div class="wps-table-cell textleft" ><?php echo esc_html($product_average); ?></div> |
|
87 | 87 | </div> |
88 | 88 | </div> |
@@ -6,23 +6,23 @@ discard block |
||
6 | 6 | * @subpackage dashboard |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; |
11 | 11 | } |
12 | 12 | |
13 | 13 | ?><div class="wps-table"> |
14 | 14 | <div class="wps-table-header wps-table-row"> |
15 | 15 | <div class="wps-table-cell"> </div> |
16 | - <div class="wps-table-cell"><?php esc_html_e( 'Order count', 'wpshop' ); ?></div> |
|
17 | - <div class="wps-table-cell"><?php esc_html_e( 'Order total amount', 'wpshop' ); ?></div> |
|
18 | - <div class="wps-table-cell"><?php esc_html_e( 'Customer subscription', 'wpshop' ); ?></div> |
|
16 | + <div class="wps-table-cell"><?php esc_html_e('Order count', 'wpshop'); ?></div> |
|
17 | + <div class="wps-table-cell"><?php esc_html_e('Order total amount', 'wpshop'); ?></div> |
|
18 | + <div class="wps-table-cell"><?php esc_html_e('Customer subscription', 'wpshop'); ?></div> |
|
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <?php |
22 | -foreach ( $dates as $label => $date_def ) : |
|
22 | +foreach ($dates as $label => $date_def) : |
|
23 | 23 | |
24 | 24 | $args = array(); |
25 | - if ( is_array( $date_def ) ) : |
|
25 | + if (is_array($date_def)) : |
|
26 | 26 | $args = array( |
27 | 27 | 'date_query' => $date_def, |
28 | 28 | ); |
@@ -30,35 +30,35 @@ discard block |
||
30 | 30 | |
31 | 31 | $orders_total_amount = 0; |
32 | 32 | $order_count = 0; |
33 | - if ( null !== $shop_orders ) : |
|
34 | - foreach ( $shop_orders as $order ) : |
|
33 | + if (null !== $shop_orders) : |
|
34 | + foreach ($shop_orders as $order) : |
|
35 | 35 | $order_data = $order['order_postmeta']; |
36 | - if ( empty( $args ) ) : |
|
36 | + if (empty($args)) : |
|
37 | 37 | $orders_total_amount += $order_data['order_grand_total']; |
38 | - $order_count = count( $shop_orders ); |
|
39 | - elseif ( ( $date_def['after'] <= $order_data['order_date'] ) && ( $date_def['before'] >= $order_data['order_date'] ) ) : |
|
38 | + $order_count = count($shop_orders); |
|
39 | + elseif (($date_def['after'] <= $order_data['order_date']) && ($date_def['before'] >= $order_data['order_date'])) : |
|
40 | 40 | $orders_total_amount += $order_data['order_grand_total']; |
41 | 41 | $order_count++; |
42 | 42 | endif; |
43 | 43 | endforeach; |
44 | 44 | endif; |
45 | 45 | |
46 | - $user_subscription_number = new WP_User_Query( array( |
|
46 | + $user_subscription_number = new WP_User_Query(array( |
|
47 | 47 | 'date_query' => $date_def, |
48 | 48 | 'count_total' => true, |
49 | - ) ); |
|
49 | + )); |
|
50 | 50 | ?> |
51 | 51 | |
52 | 52 | <div class="wps-table-row"> |
53 | - <div class="wps-table-cell textleft"><?php echo esc_html( $label ); ?></div> |
|
54 | - <?php if ( null !== $shop_orders ) : ?> |
|
55 | - <div class="wps-table-cell"><?php echo esc_html( $order_count ); ?></div> |
|
56 | - <div class="wps-table-cell"><?php echo esc_html( number_format( $orders_total_amount, 2, '.', '' ) . ' ' . wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
|
53 | + <div class="wps-table-cell textleft"><?php echo esc_html($label); ?></div> |
|
54 | + <?php if (null !== $shop_orders) : ?> |
|
55 | + <div class="wps-table-cell"><?php echo esc_html($order_count); ?></div> |
|
56 | + <div class="wps-table-cell"><?php echo esc_html(number_format($orders_total_amount, 2, '.', '') . ' ' . wpshop_tools::wpshop_get_currency(false)); ?></div> |
|
57 | 57 | <?php else : ?> |
58 | - <div class="wps-table-cell"><?php esc_html_e( 'No orders have been placed for the moment', 'wpshop' ); ?></div> |
|
58 | + <div class="wps-table-cell"><?php esc_html_e('No orders have been placed for the moment', 'wpshop'); ?></div> |
|
59 | 59 | <div class="wps-table-cell"> </div> |
60 | 60 | <?php endif; ?> |
61 | - <div class="wps-table-cell"><?php echo esc_html( $user_subscription_number->get_total() ); ?></div> |
|
61 | + <div class="wps-table-cell"><?php echo esc_html($user_subscription_number->get_total()); ?></div> |
|
62 | 62 | </div> |
63 | 63 | |
64 | 64 | <?php endforeach; ?> |
@@ -54,8 +54,11 @@ |
||
54 | 54 | <?php if ( null !== $shop_orders ) : ?> |
55 | 55 | <div class="wps-table-cell"><?php echo esc_html( $order_count ); ?></div> |
56 | 56 | <div class="wps-table-cell"><?php echo esc_html( number_format( $orders_total_amount, 2, '.', '' ) . ' ' . wpshop_tools::wpshop_get_currency( false ) ); ?></div> |
57 | - <?php else : ?> |
|
58 | - <div class="wps-table-cell"><?php esc_html_e( 'No orders have been placed for the moment', 'wpshop' ); ?></div> |
|
57 | + <?php else { |
|
58 | + : ?> |
|
59 | + <div class="wps-table-cell"><?php esc_html_e( 'No orders have been placed for the moment', 'wpshop' ); |
|
60 | +} |
|
61 | +?></div> |
|
59 | 62 | <div class="wps-table-cell"> </div> |
60 | 63 | <?php endif; ?> |
61 | 64 | <div class="wps-table-cell"><?php echo esc_html( $user_subscription_number->get_total() ); ?></div> |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if (!defined('ABSPATH')) exit; |
|
2 | 2 | |
3 | 3 | /** Get hourly orders ***/ |
4 | 4 | class wps_statistics_mdl { |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * Return most viewed products statistics |
11 | 11 | * @return array |
12 | 12 | */ |
13 | - function wps_most_viewed_products_datas( $product_number = 8 ) { |
|
13 | + function wps_most_viewed_products_datas($product_number = 8) { |
|
14 | 14 | global $wpdb; |
15 | 15 | $output = ''; |
16 | 16 | $query = $wpdb->prepare( |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | AND meta_key = %s |
22 | 22 | ORDER BY CAST( meta_value AS SIGNED ) DESC |
23 | 23 | LIMIT " . $product_number, 'publish', '_wpshop_product_view_nb'); |
24 | - $products = $wpdb->get_results( $query ); |
|
24 | + $products = $wpdb->get_results($query); |
|
25 | 25 | return $products; |
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Returns all orders and save in variable |
30 | 30 | */ |
31 | - function wps_orders_all( $custom_args = array() ) { |
|
31 | + function wps_orders_all($custom_args = array()) { |
|
32 | 32 | $orders_default_args = array( |
33 | 33 | 'posts_per_page' => -1, |
34 | 34 | 'orderby' => 'post_date', |
@@ -56,12 +56,12 @@ discard block |
||
56 | 56 | ); |
57 | 57 | |
58 | 58 | $orders = null; |
59 | - $orders_query = new WP_Query( wp_parse_args( $custom_args, $orders_default_args ) ); |
|
60 | - if ( $orders_query->have_posts() ) { |
|
61 | - foreach( $orders_query->posts as $order ) { |
|
62 | - $orders[ $order->ID ]['post'] = $order; |
|
63 | - $orders[ $order->ID ]['order_postmeta'] = get_post_meta( $order->ID, '_order_postmeta', true ); |
|
64 | - $orders[ $order->ID ]['order_info'] = get_post_meta( $order->ID, '_order_info', true ); |
|
59 | + $orders_query = new WP_Query(wp_parse_args($custom_args, $orders_default_args)); |
|
60 | + if ($orders_query->have_posts()) { |
|
61 | + foreach ($orders_query->posts as $order) { |
|
62 | + $orders[$order->ID]['post'] = $order; |
|
63 | + $orders[$order->ID]['order_postmeta'] = get_post_meta($order->ID, '_order_postmeta', true); |
|
64 | + $orders[$order->ID]['order_info'] = get_post_meta($order->ID, '_order_info', true); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
@@ -74,24 +74,24 @@ discard block |
||
74 | 74 | * @param string $enddate |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - function wps_best_sales_datas( $begindate, $enddate) { |
|
78 | - $begindate = new DateTime( $begindate.' 00:00:00' ); |
|
79 | - $enddate = new DateTime( $enddate.' 23:59:59' ); |
|
77 | + function wps_best_sales_datas($begindate, $enddate) { |
|
78 | + $begindate = new DateTime($begindate . ' 00:00:00'); |
|
79 | + $enddate = new DateTime($enddate . ' 23:59:59'); |
|
80 | 80 | $orders = $this->wps_orders_all(); |
81 | - if ( !empty($orders) ) { |
|
81 | + if (!empty($orders)) { |
|
82 | 82 | $products = array(); |
83 | - foreach( $orders as $order ) { |
|
84 | - $date_order = new DateTime( $order->post_date ); |
|
85 | - if( $begindate <= $date_order && $date_order <= $enddate ) { |
|
83 | + foreach ($orders as $order) { |
|
84 | + $date_order = new DateTime($order->post_date); |
|
85 | + if ($begindate <= $date_order && $date_order <= $enddate) { |
|
86 | 86 | $order_meta = $order->_order_postmeta; |
87 | - if( !empty($order_meta) && !empty($order_meta['order_items']) ) { |
|
88 | - foreach( $order_meta['order_items'] as $item_id => $item ) { |
|
89 | - if( !empty($item) && !empty($item['item_qty']) && !empty($item['item_id']) ) { |
|
90 | - if( !empty($products[ $item['item_id'] ]) ) { |
|
91 | - $products[ $item['item_id'] ] += $item['item_qty']; |
|
87 | + if (!empty($order_meta) && !empty($order_meta['order_items'])) { |
|
88 | + foreach ($order_meta['order_items'] as $item_id => $item) { |
|
89 | + if (!empty($item) && !empty($item['item_qty']) && !empty($item['item_id'])) { |
|
90 | + if (!empty($products[$item['item_id']])) { |
|
91 | + $products[$item['item_id']] += $item['item_qty']; |
|
92 | 92 | } |
93 | 93 | else { |
94 | - $products[ $item['item_id'] ] = $item['item_qty']; |
|
94 | + $products[$item['item_id']] = $item['item_qty']; |
|
95 | 95 | } |
96 | 96 | } |
97 | 97 | } |
@@ -110,20 +110,20 @@ discard block |
||
110 | 110 | $output = ''; |
111 | 111 | $order_recap = array(); |
112 | 112 | $orders = $this->wps_orders_all(); |
113 | - if ( !empty($orders) ) { |
|
114 | - foreach( $orders as $order ) { |
|
115 | - $order_year = date( 'Y', strtotime( $order->post_date) ); |
|
116 | - $order_month = date( 'n', strtotime( $order->post_date) ); |
|
117 | - if ( empty($order_recap[$order_year]) ) { |
|
113 | + if (!empty($orders)) { |
|
114 | + foreach ($orders as $order) { |
|
115 | + $order_year = date('Y', strtotime($order->post_date)); |
|
116 | + $order_month = date('n', strtotime($order->post_date)); |
|
117 | + if (empty($order_recap[$order_year])) { |
|
118 | 118 | $order_recap[$order_year] = array(); |
119 | 119 | } |
120 | 120 | $order_meta = $order->_order_postmeta; |
121 | - if ( !empty($order_meta) && !empty($order_meta['order_grand_total']) ) { |
|
122 | - if ( empty($order_recap[$order_year][ $order_month ]) ) { |
|
123 | - $order_recap[$order_year][ $order_month ] = $order_meta['order_grand_total']; |
|
121 | + if (!empty($order_meta) && !empty($order_meta['order_grand_total'])) { |
|
122 | + if (empty($order_recap[$order_year][$order_month])) { |
|
123 | + $order_recap[$order_year][$order_month] = $order_meta['order_grand_total']; |
|
124 | 124 | } |
125 | 125 | else { |
126 | - $order_recap[$order_year][ $order_month ] += $order_meta['order_grand_total']; |
|
126 | + $order_recap[$order_year][$order_month] += $order_meta['order_grand_total']; |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 | } |
@@ -136,24 +136,24 @@ discard block |
||
136 | 136 | * Orders Status |
137 | 137 | * @return Array |
138 | 138 | */ |
139 | - function wps_order_status( $begin_date, $end_date ) { |
|
140 | - $begin_date = new DateTime( $begin_date.' 00:00:00' ); |
|
141 | - $end_date = new DateTime( $end_date.' 23:59:59' ); |
|
139 | + function wps_order_status($begin_date, $end_date) { |
|
140 | + $begin_date = new DateTime($begin_date . ' 00:00:00'); |
|
141 | + $end_date = new DateTime($end_date . ' 23:59:59'); |
|
142 | 142 | $output = ''; |
143 | 143 | $orders = $this->wps_orders_all(); |
144 | - if ( !empty($orders) ) { |
|
144 | + if (!empty($orders)) { |
|
145 | 145 | $orders_status = array(); |
146 | 146 | /** Collect datas **/ |
147 | - foreach( $orders as $order ) { |
|
148 | - $date_order = new DateTime( $order->post_date ); |
|
149 | - if( $begin_date <= $date_order && $date_order <= $end_date ) { |
|
147 | + foreach ($orders as $order) { |
|
148 | + $date_order = new DateTime($order->post_date); |
|
149 | + if ($begin_date <= $date_order && $date_order <= $end_date) { |
|
150 | 150 | $order_meta = $order->_order_postmeta; |
151 | - if ( !empty($order_meta) && !empty($order_meta['order_status']) ) { |
|
152 | - if ( !empty($orders_status[ $order_meta['order_status'] ]) ) { |
|
153 | - $orders_status[ $order_meta['order_status'] ]++; |
|
151 | + if (!empty($order_meta) && !empty($order_meta['order_status'])) { |
|
152 | + if (!empty($orders_status[$order_meta['order_status']])) { |
|
153 | + $orders_status[$order_meta['order_status']]++; |
|
154 | 154 | } |
155 | 155 | else { |
156 | - $orders_status[ $order_meta['order_status'] ] = 1; |
|
156 | + $orders_status[$order_meta['order_status']] = 1; |
|
157 | 157 | } |
158 | 158 | } |
159 | 159 | } |
@@ -168,32 +168,32 @@ discard block |
||
168 | 168 | * @param string $end_date |
169 | 169 | * @return array |
170 | 170 | */ |
171 | - function wps_best_customers( $begin_date, $end_date ) { |
|
171 | + function wps_best_customers($begin_date, $end_date) { |
|
172 | 172 | $output = ''; |
173 | 173 | $customer_recap = array(); |
174 | 174 | |
175 | - $begin_date = new DateTime( $begin_date.' 00:00:00' ); |
|
176 | - $end_date = new DateTime( $end_date.' 23:59:59' ); |
|
175 | + $begin_date = new DateTime($begin_date . ' 00:00:00'); |
|
176 | + $end_date = new DateTime($end_date . ' 23:59:59'); |
|
177 | 177 | $orders = $this->wps_orders_all(); |
178 | 178 | |
179 | - if ( !empty($orders) ) { |
|
180 | - foreach( $orders as $order ) { |
|
181 | - $date_order = new DateTime( $order->post_date ); |
|
182 | - if( $begin_date <= $date_order && $date_order <= $end_date ) { |
|
179 | + if (!empty($orders)) { |
|
180 | + foreach ($orders as $order) { |
|
181 | + $date_order = new DateTime($order->post_date); |
|
182 | + if ($begin_date <= $date_order && $date_order <= $end_date) { |
|
183 | 183 | $order_meta = $order->_order_postmeta; |
184 | - if ( !empty($order_meta) && !empty($order_meta['customer_id']) && !empty($order_meta['order_grand_total']) ) { |
|
184 | + if (!empty($order_meta) && !empty($order_meta['customer_id']) && !empty($order_meta['order_grand_total'])) { |
|
185 | 185 | /** Check if user is administrator **/ |
186 | - $user_def = get_user_by( 'id', $order_meta['customer_id'] ); |
|
187 | - $wps_statistics_exclude_customer = get_user_meta( $order_meta['customer_id'], 'wps_statistics_exclude_customer', true ); |
|
188 | - $excluded_from_statistics = ( !empty($wps_statistics_exclude_customer) ) ? true : false; |
|
186 | + $user_def = get_user_by('id', $order_meta['customer_id']); |
|
187 | + $wps_statistics_exclude_customer = get_user_meta($order_meta['customer_id'], 'wps_statistics_exclude_customer', true); |
|
188 | + $excluded_from_statistics = (!empty($wps_statistics_exclude_customer)) ? true : false; |
|
189 | 189 | |
190 | 190 | |
191 | - if ( !empty($user_def) && !empty($user_def->caps) && is_array($user_def->caps) && array_key_exists( 'customer', $user_def->caps) && $excluded_from_statistics === false ) { |
|
192 | - if ( empty($customer_recap[ $order_meta['customer_id'] ] ) ) { |
|
193 | - $customer_recap[ $order_meta['customer_id'] ] = $order_meta['order_grand_total']; |
|
191 | + if (!empty($user_def) && !empty($user_def->caps) && is_array($user_def->caps) && array_key_exists('customer', $user_def->caps) && $excluded_from_statistics === false) { |
|
192 | + if (empty($customer_recap[$order_meta['customer_id']])) { |
|
193 | + $customer_recap[$order_meta['customer_id']] = $order_meta['order_grand_total']; |
|
194 | 194 | } |
195 | 195 | else { |
196 | - $customer_recap[ $order_meta['customer_id'] ] += $order_meta['order_grand_total']; |
|
196 | + $customer_recap[$order_meta['customer_id']] += $order_meta['order_grand_total']; |
|
197 | 197 | } |
198 | 198 | } |
199 | 199 | } |
@@ -206,22 +206,22 @@ discard block |
||
206 | 206 | |
207 | 207 | |
208 | 208 | |
209 | - function wps_get_orders_by_hours( $begindate, $enddate, $choosenday = '', $ajax_origin = false ) { |
|
210 | - $begin_date = new DateTime( $begindate.' 00:00:00' ); |
|
211 | - $end_date = new DateTime( $enddate.' 23:59:59' ); |
|
209 | + function wps_get_orders_by_hours($begindate, $enddate, $choosenday = '', $ajax_origin = false) { |
|
210 | + $begin_date = new DateTime($begindate . ' 00:00:00'); |
|
211 | + $end_date = new DateTime($enddate . ' 23:59:59'); |
|
212 | 212 | $resultarray = $this->wps_orders_all(); |
213 | 213 | |
214 | 214 | $datadate = array(); |
215 | - foreach ($resultarray as $array){ |
|
216 | - $date = new DateTime( $array->post_date ); |
|
217 | - if( $begin_date <= $date && $date <= $end_date ) { |
|
215 | + foreach ($resultarray as $array) { |
|
216 | + $date = new DateTime($array->post_date); |
|
217 | + if ($begin_date <= $date && $date <= $end_date) { |
|
218 | 218 | $day = $date->format('l'); |
219 | 219 | $day = strtolower($day); |
220 | 220 | $choosenday = strtolower($choosenday); |
221 | - if( empty($choosenday) || ( !empty($choosenday) && $choosenday == $day ) ) { |
|
221 | + if (empty($choosenday) || (!empty($choosenday) && $choosenday == $day)) { |
|
222 | 222 | $hour = $date->format('G'); |
223 | - if ( empty($datadate[$day])){ |
|
224 | - if (empty($datadate[$day][$hour])){ |
|
223 | + if (empty($datadate[$day])) { |
|
224 | + if (empty($datadate[$day][$hour])) { |
|
225 | 225 | $datadate[$day][$hour] = 1; |
226 | 226 | } |
227 | 227 | else { |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | } |
230 | 230 | } |
231 | 231 | else { |
232 | - if (empty($datadate[$day][$hour])){ |
|
232 | + if (empty($datadate[$day][$hour])) { |
|
233 | 233 | $datadate[$day][$hour] = 1; |
234 | 234 | } |
235 | 235 | else { |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( !defined( 'ABSPATH' ) ) exit; |
|
1 | +<?php if ( !defined( 'ABSPATH' ) ) { |
|
2 | + exit; |
|
3 | +} |
|
2 | 4 | |
3 | 5 | /** Get hourly orders ***/ |
4 | 6 | class wps_statistics_mdl { |
@@ -89,8 +91,7 @@ discard block |
||
89 | 91 | if( !empty($item) && !empty($item['item_qty']) && !empty($item['item_id']) ) { |
90 | 92 | if( !empty($products[ $item['item_id'] ]) ) { |
91 | 93 | $products[ $item['item_id'] ] += $item['item_qty']; |
92 | - } |
|
93 | - else { |
|
94 | + } else { |
|
94 | 95 | $products[ $item['item_id'] ] = $item['item_qty']; |
95 | 96 | } |
96 | 97 | } |
@@ -121,8 +122,7 @@ discard block |
||
121 | 122 | if ( !empty($order_meta) && !empty($order_meta['order_grand_total']) ) { |
122 | 123 | if ( empty($order_recap[$order_year][ $order_month ]) ) { |
123 | 124 | $order_recap[$order_year][ $order_month ] = $order_meta['order_grand_total']; |
124 | - } |
|
125 | - else { |
|
125 | + } else { |
|
126 | 126 | $order_recap[$order_year][ $order_month ] += $order_meta['order_grand_total']; |
127 | 127 | } |
128 | 128 | } |
@@ -151,8 +151,7 @@ discard block |
||
151 | 151 | if ( !empty($order_meta) && !empty($order_meta['order_status']) ) { |
152 | 152 | if ( !empty($orders_status[ $order_meta['order_status'] ]) ) { |
153 | 153 | $orders_status[ $order_meta['order_status'] ]++; |
154 | - } |
|
155 | - else { |
|
154 | + } else { |
|
156 | 155 | $orders_status[ $order_meta['order_status'] ] = 1; |
157 | 156 | } |
158 | 157 | } |
@@ -191,8 +190,7 @@ discard block |
||
191 | 190 | if ( !empty($user_def) && !empty($user_def->caps) && is_array($user_def->caps) && array_key_exists( 'customer', $user_def->caps) && $excluded_from_statistics === false ) { |
192 | 191 | if ( empty($customer_recap[ $order_meta['customer_id'] ] ) ) { |
193 | 192 | $customer_recap[ $order_meta['customer_id'] ] = $order_meta['order_grand_total']; |
194 | - } |
|
195 | - else { |
|
193 | + } else { |
|
196 | 194 | $customer_recap[ $order_meta['customer_id'] ] += $order_meta['order_grand_total']; |
197 | 195 | } |
198 | 196 | } |
@@ -223,16 +221,13 @@ discard block |
||
223 | 221 | if ( empty($datadate[$day])){ |
224 | 222 | if (empty($datadate[$day][$hour])){ |
225 | 223 | $datadate[$day][$hour] = 1; |
226 | - } |
|
227 | - else { |
|
224 | + } else { |
|
228 | 225 | $datadate[$day][$hour] += 1; |
229 | 226 | } |
230 | - } |
|
231 | - else { |
|
227 | + } else { |
|
232 | 228 | if (empty($datadate[$day][$hour])){ |
233 | 229 | $datadate[$day][$hour] = 1; |
234 | - } |
|
235 | - else { |
|
230 | + } else { |
|
236 | 231 | $datadate[$day][$hour] += 1; |
237 | 232 | } |
238 | 233 | } |