Changeset 3138223
- Timestamp:
- 08/20/2024 02:01:00 PM (18 months ago)
- Location:
- ni-woocommerce-dashboard-report
- Files:
-
- 19 added
- 5 edited
-
tags/2.2.8 (added)
-
tags/2.2.8/assets (added)
-
tags/2.2.8/assets/css (added)
-
tags/2.2.8/assets/css/ni-dashboard-report-style.css (added)
-
tags/2.2.8/include (added)
-
tags/2.2.8/include/ni-dashboard-report.php (added)
-
tags/2.2.8/index.html (added)
-
tags/2.2.8/languages (added)
-
tags/2.2.8/languages/nidashboardreport-it_IT.mo (added)
-
tags/2.2.8/languages/nidashboardreport-it_IT.po (added)
-
tags/2.2.8/ni-woocommerce-dashboard-report.php (added)
-
tags/2.2.8/readme.txt (added)
-
tags/2.2.8/screenshot-1.png (added)
-
tags/2.2.8/screenshot-2.png (added)
-
tags/2.2.8/screenshot-3.png (added)
-
tags/2.2.8/screenshot-4.png (added)
-
tags/2.2.8/screenshot-5.png (added)
-
tags/2.2.8/screenshot-6.png (added)
-
tags/2.2.8/screenshot-7.png (added)
-
tags/2.2.9/ni-woocommerce-dashboard-report.php (modified) (1 diff)
-
tags/2.2.9/readme.txt (modified) (2 diffs)
-
trunk/include/ni-dashboard-report.php (modified) (15 diffs)
-
trunk/ni-woocommerce-dashboard-report.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ni-woocommerce-dashboard-report/tags/2.2.9/ni-woocommerce-dashboard-report.php
r3138221 r3138223 3 3 Plugin Name: Ni WooCommerce Dashboard Sales Report 4 4 Plugin URI: http://naziinfotech.com/ 5 Description: Enhance your WooCommerce store 's performance with the "Ni WooCommerce Dashboard Report" plugin. Gain valuable insights, track sales, and optimize your online business for success.5 Description: Enhance your WooCommerce store with the "Ni WooCommerce Dashboard Report" plugin. Gain insights, track sales, and optimize your business. 6 6 Version: 2.2.9 7 7 Author: anzia -
ni-woocommerce-dashboard-report/tags/2.2.9/readme.txt
r3138221 r3138223 1 1 === Ni WooCommerce Dashboard Sales Report === 2 2 Contributors: anzia 3 Tags: report, sales, order,customer, sales report, order report, woocommerce reports, new customer3 Tags: dashboard report, order status report, sales report, customer report 4 4 Stable tag: 2.2.9 5 5 License: GPLv3 or later … … 15 15 16 16 17 Enhance your WooCommerce store 's performance with the "Ni WooCommerce Dashboard Report" plugin. Gain valuable insights, track sales, and optimize your online business for success. Download now!17 Enhance your WooCommerce store with the "Ni WooCommerce Dashboard Report" plugin. Gain insights, track sales, and optimize your business. 18 18 19 19 == Description == -
ni-woocommerce-dashboard-report/trunk/include/ni-dashboard-report.php
r2518049 r3138223 3 3 if( !class_exists( 'ni_dashboard_report' ) ) { 4 4 class ni_dashboard_report{ 5 var $is_hpos_enable = false; 6 private $months; 5 7 public function __construct(){ 6 8 add_action('admin_init', array( &$this, 'admin_init')); 7 9 add_action( 'admin_enqueue_scripts', array(&$this,'ni_admin_enqueue_scripts' )); 8 10 //add_filter( 'gettext', array($this, 'get_text'),20,3); 11 $this->is_hpos_enable = $this->is_hpos_enabled(); 12 9 13 } 10 14 function get_text($translated_text, $text, $domain){ … … 14 18 return $translated_text; 15 19 } 20 function is_hpos_enabled() { 21 if ( ! class_exists( 'Automattic\\WooCommerce\\Utilities\\OrderUtil' ) ) { 22 return false; // OrderUtil class doesn't exist, HPOS is likely not enabled 23 } 24 25 return Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled(); 26 } 16 27 function admin_init(){ 17 28 add_action( 'wp_dashboard_setup', array( &$this, 'ni_add_dashboard_widgets' )); … … 75 86 } 76 87 function ni_woocommerce_top_sold_product_widget(){ 77 global $wpdb; 88 89 90 global $wpdb; 78 91 $query = " SELECT "; 79 92 $query .= " SUM(qty.meta_value) as qty "; 80 93 $query .= " ,ROUND(SUM(line_total.meta_value),2) as line_total "; 81 94 $query .= " ,line_item.order_item_name as order_item_name "; 82 $query .= " FROM {$wpdb->prefix}posts as posts "; 95 if ( $this->is_hpos_enable){ 96 $query .= " FROM {$wpdb->prefix}wc_orders as posts "; 97 }else{ 98 $query .= " FROM {$wpdb->prefix}posts as posts "; 99 } 100 83 101 $query .= " LEFT JOIN {$wpdb->prefix}woocommerce_order_items as line_item ON line_item.order_id=posts.ID " ; 84 102 … … 91 109 92 110 $query .= " WHERE 1=1 "; 93 $query .= " AND posts.post_type ='shop_order' "; 111 if ( $this->is_hpos_enable){ 112 $query .= " AND posts.type ='shop_order' "; 113 }else{ 114 $query .= " AND posts.post_type ='shop_order' "; 115 } 116 94 117 $query .= " AND qty.meta_key ='_qty' "; 95 118 $query .= " AND product_id.meta_key ='_product_id' "; … … 98 121 $query .= " AND line_item.order_item_type ='line_item' "; 99 122 $query .= " AND line_total.meta_key ='_line_total' "; 100 $query .= " AND posts.post_status IN ('wc-processing','wc-on-hold', 'wc-completed')"; 101 102 $query .= " AND posts.post_status NOT IN ('trash')"; 123 if ( $this->is_hpos_enable){ 124 $query .= " AND posts.status IN ('wc-processing','wc-on-hold', 'wc-completed')"; 125 $query .= " AND posts.status NOT IN ('trash')"; 126 }else{ 127 $query .= " AND posts.post_status IN ('wc-processing','wc-on-hold', 'wc-completed')"; 128 $query .= " AND posts.post_status NOT IN ('trash')"; 129 } 130 131 132 103 133 $query .= " GROUP BY product_id.meta_value, variation_id.meta_value "; 104 134 $query .= " ORDER BY SUM(qty.meta_value) + 0 DESC "; … … 147 177 148 178 $query = ""; 149 $query = " SELECT "; 150 $query .= " SUM(order_total.meta_value) as order_total"; 151 $query .= ", date_format( posts.post_date, '%Y-%m') as month"; 152 $query .= " FROM {$wpdb->prefix}posts as posts "; 179 $query .= " SELECT "; 180 181 182 //$query .= " FROM {$wpdb->prefix}posts as posts "; 183 184 if ( $this->is_hpos_enable){ 185 $query .= " SUM(total_amount) as order_total"; 186 $query .= ", date_format( posts.date_created_gmt, '%Y-%m') as month"; 187 $query .= " FROM {$wpdb->prefix}wc_orders as posts "; 188 }else{ 189 $query .= " SUM(order_total.meta_value) as order_total"; 190 $query .= ", date_format( posts.post_date, '%Y-%m') as month"; 191 $query .= " FROM {$wpdb->prefix}posts as posts "; 153 192 $query .= " LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID "; 193 } 194 195 154 196 $query .= " WHERE 1=1 "; 155 $query .= " AND posts.post_type = 'shop_order'"; 156 $query .= " AND order_total.meta_key = '_order_total'"; 157 158 $query .= " AND date_format( posts.post_date, '%Y-%m-%d') BETWEEN '{$start_date}' AND '{$end_date}'"; 159 160 $query .= " AND posts.post_status IN ('{$order_status}') "; 161 162 163 $query .= " GROUP BY YEAR(posts.post_date), MONTH(posts.post_date) "; 197 //$query .= " AND posts.post_type = 'shop_order'"; 198 199 if ( $this->is_hpos_enable){ 200 $query .= " AND posts.type ='shop_order' "; 201 }else{ 202 $query .= " AND posts.post_type ='shop_order' "; 203 } 204 205 if ( $this->is_hpos_enable){ 206 //$query .= " AND order_total.meta_key = '_order_total'"; 207 $query .= " AND date_format( posts.date_created_gmt, '%Y-%m-%d') BETWEEN '{$start_date}' AND '{$end_date}'"; 208 $query .= " AND posts.status IN ('{$order_status}') "; 209 $query .= " GROUP BY YEAR(posts.date_created_gmt), MONTH(posts.date_created_gmt) "; 210 } else{ 211 $query .= " AND order_total.meta_key = '_order_total'"; 212 $query .= " AND date_format( posts.post_date, '%Y-%m-%d') BETWEEN '{$start_date}' AND '{$end_date}'"; 213 $query .= " AND posts.post_status IN ('{$order_status}') "; 214 $query .= " GROUP BY YEAR(posts.post_date), MONTH(posts.post_date) "; 215 } 216 217 218 164 219 $row = $wpdb->get_results($query); 165 220 $_net_amount = array(); … … 173 228 $query = ""; 174 229 $query = " SELECT "; 230 175 231 $query .= " SUM(order_itemmeta.meta_value) as order_total"; 176 $query .= ", date_format( posts.post_date, '%Y-%m') as month"; 177 $query .= " FROM {$wpdb->prefix}posts as posts "; 232 if ( $this->is_hpos_enable){ 233 $query .= ", date_format( posts.date_created_gmt, '%Y-%m') as month"; 234 }else{ 235 $query .= ", date_format( posts.post_date, '%Y-%m') as month"; 236 } 237 238 if ( $this->is_hpos_enable){ 239 $query .= " FROM {$wpdb->prefix}wc_orders as posts "; 240 }else{ 241 $query .= " FROM {$wpdb->prefix}posts as posts "; 242 } 243 178 244 179 245 $query .= " LEFT JOIN {$wpdb->prefix}woocommerce_order_items as order_items ON order_items.order_id=posts.ID "; … … 182 248 183 249 $query .= " WHERE 1=1 "; 184 $query .= " AND posts.post_type = 'shop_order'"; 250 251 if ( $this->is_hpos_enable){ 252 $query .= " AND posts.type ='shop_order' "; 253 }else{ 254 $query .= " AND posts.post_type ='shop_order' "; 255 } 256 257 185 258 $query .= " AND order_itemmeta.meta_key = '_line_total'"; 186 $query .= " AND date_format( posts.post_date, '%Y-%m-%d') BETWEEN '{$start_date}' AND '{$end_date}'"; 187 $query .= " AND posts.post_status IN ('{$order_status}') "; 188 $query .= " GROUP BY YEAR(posts.post_date), MONTH(posts.post_date) "; 259 260 if ( $this->is_hpos_enable){ 261 $query .= " AND date_format( posts.date_created_gmt, '%Y-%m-%d') BETWEEN '{$start_date}' AND '{$end_date}'"; 262 $query .= " AND posts.status IN ('{$order_status}') "; 263 $query .= " GROUP BY YEAR(posts.date_created_gmt), MONTH(posts.date_created_gmt) "; 264 }else{ 265 $query .= " AND date_format( posts.post_date, '%Y-%m-%d') BETWEEN '{$start_date}' AND '{$end_date}'"; 266 $query .= " AND posts.post_status IN ('{$order_status}') "; 267 $query .= " GROUP BY YEAR(posts.post_date), MONTH(posts.post_date) "; 268 } 269 270 189 271 $row = $wpdb->get_results($query); 190 272 $_gross_amount = array(); … … 271 353 } 272 354 function ni_woocommerce_sales_analysis_widget(){ 273 $order_data = $this->get_sales_analysis(); 274 //$this->print_array($order_data); 355 $order_data = array(); 356 357 358 359 if ( $this->is_hpos_enable){ 360 $order_data = $this->get_sales_analysis_hpos(); 361 }else{ 362 $order_data = $this->get_sales_analysis(); 363 } 364 275 365 ?> 276 366 <div style="overflow-x:auto;"> … … 338 428 function get_recent_orders(){ 339 429 global $wpdb; 340 341 $query = " SELECT 342 posts.ID as order_id 343 ,posts.post_status as order_status 344 , date_format( posts.post_date, '%Y-%m-%d') as order_date 345 346 FROM {$wpdb->prefix}posts as posts "; 430 431 $query = ""; 432 433 $query .= " SELECT "; 434 435 436 if ( $this->is_hpos_enable){ 437 $query .= " posts.ID as order_id"; 438 $query .= " ,posts.status as order_status"; 439 $query .= " , date_format( posts.date_created_gmt, '%Y-%m-%d') as order_date "; 440 $query .= " FROM {$wpdb->prefix}wc_orders as posts "; 441 }else{ 442 $query .= " posts.ID as order_id"; 443 $query .= " ,posts.post_status as order_status"; 444 $query .= " , date_format( posts.post_date, '%Y-%m-%d') as order_date "; 445 $query .= " FROM {$wpdb->prefix}posts as posts "; 446 } 447 347 448 348 449 $query .= " WHERE 1=1 "; 349 $query .= " AND posts.post_type = 'shop_order'"; 350 $query .= " AND posts.post_status NOT IN ('auto-draft')"; 351 352 $query .= "order by posts.post_date DESC"; 450 if ( $this->is_hpos_enable){ 451 $query .= " AND posts.type = 'shop_order'"; 452 $query .= " AND posts.status NOT IN ('auto-draft')"; 453 $query .= "order by posts.date_created_gmt DESC"; 454 }else{ 455 $query .= " AND posts.post_type = 'shop_order'"; 456 $query .= " AND posts.post_status NOT IN ('auto-draft')"; 457 $query .= "order by posts.post_date DESC"; 458 } 459 460 461 353 462 $query .= " LIMIT 5"; 354 463 $order_data = $wpdb->get_results( $query); … … 389 498 $today = date_i18n("Y-m-d"); 390 499 global $wpdb; 391 $query = "SELECT 392 SUM(order_total.meta_value)as 'total_sales' 393 ,count(*) as order_count 394 ,'Today' as 'order_day' 395 ,'#AD1457' as 'color' 396 FROM {$wpdb->prefix}posts as posts 397 LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID 500 $query = ""; 501 $query .= " SELECT "; 502 $query .= " SUM(order_total.meta_value)as 'total_sales'"; 503 $query .= " ,count(*) as order_count"; 504 $query .= " ,'Today' as 'order_day'"; 505 $query .= " ,'#AD1457' as 'color'"; 506 $query .= " FROM {$wpdb->prefix}posts as posts"; 507 $query .= " LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID "; 398 508 399 WHERE 1=1400 AND posts.post_type ='shop_order'401 AND order_total.meta_key='_order_total' ";402 403 $query .= " AND date_format( posts.post_date, '%Y-%m-%d') = date_format('{$today}', '%Y-%m-%d')";404 $query .= " AND posts.post_status IN ('{$order_status}') ";405 406 $query .= " UNION ALL ";509 $query .= " WHERE 1=1"; 510 $query .= " AND posts.post_type ='shop_order' "; 511 $query .= " AND order_total.meta_key='_order_total' "; 512 513 $query .= " AND date_format( posts.post_date, '%Y-%m-%d') = date_format('{$today}', '%Y-%m-%d')"; 514 $query .= " AND posts.post_status IN ('{$order_status}') "; 515 516 $query .= " UNION ALL "; 407 517 408 518 /*Yesterday*/ 409 $query .= "SELECT410 SUM(order_total.meta_value)as 'total_sales'411 ,count(*) as order_count412 ,'Yesterday' as 'order_day'413 ,'#6A1B9A' as 'color'414 FROM {$wpdb->prefix}posts as posts415 LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID519 $query .= "SELECT "; 520 $query .= " SUM(order_total.meta_value)as 'total_sales' "; 521 $query .= " ,count(*) as order_count "; 522 $query .= " ,'Yesterday' as 'order_day' "; 523 $query .= " ,'#6A1B9A' as 'color' "; 524 $query .= " FROM {$wpdb->prefix}posts as posts "; 525 $query .= " LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID "; 416 526 417 WHERE 1=1 418 AND posts.post_type ='shop_order' 419 AND order_total.meta_key='_order_total' "; 420 421 //$query .= " AND date_format( posts.post_date, '%Y-%m-%d') > DATE_SUB(date_format(NOW(), '%Y-%m-%d'), INTERVAL 1 WEEK) "; 422 423 //$query .= " AND date_format( posts.post_date, '%Y-%m-%d') = SUBDATE(date_format('{$today}' , '%Y-%m-%d'),1) "; 424 425 $query .= " AND date_format( posts.post_date, '%Y-%m-%d') = DATE_SUB(date_format('{$today}' , '%Y-%m-%d'), INTERVAL 1 DAY) "; 426 427 $query .= " AND posts.post_status IN ('{$order_status}') "; 428 429 $query .= " UNION ALL "; 527 $query .= " WHERE 1=1 "; 528 $query .= " AND posts.post_type ='shop_order' "; 529 $query .= " AND order_total.meta_key='_order_total' "; 530 $query .= " AND date_format( posts.post_date, '%Y-%m-%d') = DATE_SUB(date_format('{$today}' , '%Y-%m-%d'), INTERVAL 1 DAY) "; 531 $query .= " AND posts.post_status IN ('{$order_status}') "; 532 533 $query .= " UNION ALL "; 430 534 431 535 /*Week*/ 432 $query .= "SELECT433 SUM(order_total.meta_value)as 'total_sales'434 ,count(*) as order_count435 ,'This Week' as 'order_day'436 ,'#6A1B9A' as 'color'437 FROM {$wpdb->prefix}posts as posts438 LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID536 $query .= "SELECT "; 537 $query .= " SUM(order_total.meta_value)as 'total_sales'"; 538 $query .= " ,count(*) as order_count"; 539 $query .= " ,'This Week' as 'order_day'"; 540 $query .= " ,'#6A1B9A' as 'color'"; 541 $query .= " FROM {$wpdb->prefix}posts as posts "; 542 $query .= " LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID "; 439 543 440 WHERE 1=1 441 AND posts.post_type ='shop_order' 442 AND order_total.meta_key='_order_total' "; 443 444 //$query .= " AND date_format( posts.post_date, '%Y-%m-%d') > DATE_SUB(date_format(NOW(), '%Y-%m-%d'), INTERVAL 1 WEEK) "; 445 446 $query .= " AND YEAR(date_format( posts.post_date, '%Y-%m-%d')) = YEAR(CURRENT_DATE()) AND 447 WEEK(date_format( posts.post_date, '%Y-%m-%d')) = WEEK(CURRENT_DATE()) "; 448 $query .= " AND posts.post_status IN ('{$order_status}') "; 449 $query .= " UNION ALL "; 544 $query .= " WHERE 1=1"; 545 $query .= " AND posts.post_type ='shop_order' "; 546 $query .= " AND order_total.meta_key='_order_total' "; 547 $query .= " AND YEAR(date_format( posts.post_date, '%Y-%m-%d')) = YEAR(CURRENT_DATE()) AND "; 548 $query .= " WEEK(date_format( posts.post_date, '%Y-%m-%d')) = WEEK(CURRENT_DATE()) "; 549 $query .= " AND posts.post_status IN ('{$order_status}') "; 550 $query .= " UNION ALL "; 450 551 /*Month*/ 451 $query .= "SELECT452 SUM(order_total.meta_value)as 'total_sales'453 ,count(*) as order_count454 ,'This Month' as 'order_day'455 ,'#1565C0' as 'color'456 FROM {$wpdb->prefix}posts as posts457 LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID552 $query .= " SELECT "; 553 $query .= " SUM(order_total.meta_value)as 'total_sales' "; 554 $query .= " ,count(*) as order_count "; 555 $query .= " ,'This Month' as 'order_day' "; 556 $query .= " ,'#1565C0' as 'color' "; 557 $query .= " FROM {$wpdb->prefix}posts as posts "; 558 $query .= " LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID "; 458 559 459 WHERE 1=1 460 AND posts.post_type ='shop_order' 461 AND order_total.meta_key='_order_total' "; 462 463 //$query .= " AND date_format( posts.post_date, '%Y-%m-%d') > DATE_SUB(date_format(NOW(), '%Y-%m-%d'), INTERVAL 1 MONTH) "; 464 465 $query .= " AND YEAR(date_format( posts.post_date, '%Y-%m-%d')) = YEAR(CURRENT_DATE()) AND 466 MONTH(date_format( posts.post_date, '%Y-%m-%d')) = MONTH(CURRENT_DATE()) "; 467 $query .= " AND posts.post_status IN ('{$order_status}') "; 468 $query .= " UNION ALL "; 560 $query .= " WHERE 1=1 "; 561 $query .= " AND posts.post_type ='shop_order' "; 562 $query .= " AND order_total.meta_key='_order_total' "; 563 $query .= " AND YEAR(date_format( posts.post_date, '%Y-%m-%d')) = YEAR(CURRENT_DATE()) AND "; 564 $query .= " MONTH(date_format( posts.post_date, '%Y-%m-%d')) = MONTH(CURRENT_DATE()) "; 565 $query .= " AND posts.post_status IN ('{$order_status}') "; 566 567 $query .= " UNION ALL "; 469 568 /*Year*/ 470 $query .= "SELECT471 SUM(order_total.meta_value)as 'total_sales'472 ,count(*) as order_count473 ,'This Year' as 'order_day'474 ,'#FF5722' as 'color'475 FROM {$wpdb->prefix}posts as posts476 LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID569 $query .= " SELECT "; 570 $query .= " SUM(order_total.meta_value)as 'total_sales'"; 571 $query .= " ,count(*) as order_count"; 572 $query .= " ,'This Year' as 'order_day'"; 573 $query .= " ,'#FF5722' as 'color'"; 574 $query .= " FROM {$wpdb->prefix}posts as posts "; 575 $query .= " LEFT JOIN {$wpdb->prefix}postmeta as order_total ON order_total.post_id=posts.ID "; 477 576 478 WHERE 1=1 479 AND posts.post_type ='shop_order' 480 AND order_total.meta_key='_order_total' "; 481 482 $query .= " AND YEAR(date_format( posts.post_date, '%Y-%m-%d')) = YEAR(date_format(NOW(), '%Y-%m-%d')) "; 483 484 $query .= " AND posts.post_status IN ('{$order_status}') "; 577 $query .= " WHERE 1=1"; 578 $query .= " AND posts.post_type ='shop_order' "; 579 $query .= " AND order_total.meta_key='_order_total' "; 580 581 $query .= " AND YEAR(date_format( posts.post_date, '%Y-%m-%d')) = YEAR(date_format(NOW(), '%Y-%m-%d')) "; 582 583 $query .= " AND posts.post_status IN ('{$order_status}') "; 584 585 $order_data = $wpdb->get_results( $query); 586 587 return $order_data; 588 } 589 function get_sales_analysis_hpos(){ 590 $query = ""; 591 $order_status = $this->get_woo_order_status(); 592 593 $today = date_i18n("Y-m-d"); 594 global $wpdb; 595 $query = ""; 596 $query .= " SELECT "; 597 $query .= " SUM(total_amount)as 'total_sales'"; 598 $query .= " ,count(*) as order_count"; 599 $query .= " ,'Today' as 'order_day'"; 600 $query .= " ,'#AD1457' as 'color'"; 601 $query .= " FROM {$wpdb->prefix}wc_orders as posts"; 602 603 $query .= " WHERE 1=1"; 604 $query .= " AND posts.type ='shop_order' "; 605 606 $query .= " AND date_format( posts.date_created_gmt, '%Y-%m-%d') = date_format('{$today}', '%Y-%m-%d')"; 607 $query .= " AND posts.status IN ('{$order_status}') "; 608 609 $query .= " UNION ALL "; 610 611 /*Yesterday*/ 612 $query .= "SELECT "; 613 $query .= " SUM(total_amount)as 'total_sales'"; 614 $query .= " ,count(*) as order_count"; 615 $query .= " ,'Yesterday' as 'order_day' "; 616 $query .= " ,'#AD1457' as 'color'"; 617 $query .= " FROM {$wpdb->prefix}wc_orders as posts"; 618 619 620 $query .= " WHERE 1=1 "; 621 $query .= " AND posts.type ='shop_order' "; 622 623 $query .= " AND date_format( posts.date_created_gmt, '%Y-%m-%d') = DATE_SUB(date_format('{$today}' , '%Y-%m-%d'), INTERVAL 1 DAY) "; 624 $query .= " AND posts.status IN ('{$order_status}') "; 625 626 $query .= " UNION ALL "; 627 628 /*Week*/ 629 $query .= "SELECT "; 630 $query .= " SUM(total_amount)as 'total_sales'"; 631 $query .= " ,count(*) as order_count"; 632 $query .= " ,'This Week' as 'order_day'"; 633 $query .= " ,'#AD1457' as 'color'"; 634 $query .= " FROM {$wpdb->prefix}wc_orders as posts"; 635 636 $query .= " WHERE 1=1"; 637 $query .= " AND posts.type ='shop_order' "; 638 639 $query .= " AND YEAR(date_format( posts.date_created_gmt, '%Y-%m-%d')) = YEAR(CURRENT_DATE()) AND "; 640 $query .= " WEEK(date_format( posts.date_created_gmt, '%Y-%m-%d')) = WEEK(CURRENT_DATE()) "; 641 $query .= " AND posts.status IN ('{$order_status}') "; 642 $query .= " UNION ALL "; 643 /*Month*/ 644 $query .= " SELECT "; 645 $query .= " SUM(total_amount)as 'total_sales'"; 646 $query .= " ,count(*) as order_count"; 647 $query .= " ,'This Month' as 'order_day' "; 648 $query .= " ,'#AD1457' as 'color'"; 649 $query .= " FROM {$wpdb->prefix}wc_orders as posts"; 650 651 $query .= " WHERE 1=1 "; 652 $query .= " AND posts.type ='shop_order' "; 653 $query .= " AND YEAR(date_format( posts.date_created_gmt, '%Y-%m-%d')) = YEAR(CURRENT_DATE()) AND "; 654 $query .= " MONTH(date_format( posts.date_created_gmt, '%Y-%m-%d')) = MONTH(CURRENT_DATE()) "; 655 $query .= " AND posts.status IN ('{$order_status}') "; 656 657 $query .= " UNION ALL "; 658 /*Year*/ 659 $query .= " SELECT "; 660 $query .= " SUM(total_amount)as 'total_sales'"; 661 $query .= " ,count(*) as order_count"; 662 $query .= " ,'This Year' as 'order_day'"; 663 $query .= " ,'#AD1457' as 'color'"; 664 $query .= " FROM {$wpdb->prefix}wc_orders as posts"; 665 666 $query .= " WHERE 1=1"; 667 $query .= " AND posts.type ='shop_order' "; 668 669 670 $query .= " AND YEAR(date_format( posts.date_created_gmt, '%Y-%m-%d')) = YEAR(date_format(NOW(), '%Y-%m-%d')) "; 671 672 $query .= " AND posts.status IN ('{$order_status}') "; 485 673 486 674 $order_data = $wpdb->get_results( $query); … … 491 679 global $wpdb; 492 680 $query = "SELECT "; 493 $query .= " post.post_status as order_status"; 494 $query .= " , SUM(postmeta.meta_value) as order_total"; 495 $query .= " , COUNT(*) as order_count"; 496 $query .= " FROM {$wpdb->prefix}posts as post "; 497 498 $query .= "LEFT JOIN {$wpdb->prefix}postmeta as postmeta ON postmeta.post_id=post.ID "; 499 500 $query .= " WHERE 1=1 "; 501 //$query .= " AND post.post_status = 'publish'"; 502 $query .= " AND post.post_type = 'shop_order'"; 503 504 $query .= " AND postmeta.meta_key = '_order_total'"; 505 506 $query .= " GROUP BY post.post_status "; 507 $query .= " ORDER BY order_total DESC"; 681 if ($this->is_hpos_enable){ 682 $query .= " post.status as order_status"; 683 $query .= " , SUM(total_amount) as order_total"; 684 $query .= " , COUNT(*) as order_count"; 685 $query .= " FROM {$wpdb->prefix}wc_orders as post "; 686 687 688 689 $query .= " WHERE 1=1 "; 690 $query .= " AND post.type = 'shop_order'"; 691 692 693 $query .= " GROUP BY post.status "; 694 $query .= " ORDER BY SUM(total_amount) DESC"; 695 }else{ 696 $query .= " post.post_status as order_status"; 697 $query .= " , SUM(postmeta.meta_value) as order_total"; 698 $query .= " , COUNT(*) as order_count"; 699 $query .= " FROM {$wpdb->prefix}posts as post "; 700 701 $query .= "LEFT JOIN {$wpdb->prefix}postmeta as postmeta ON postmeta.post_id=post.ID "; 702 703 $query .= " WHERE 1=1 "; 704 $query .= " AND post.post_type = 'shop_order'"; 705 $query .= " AND postmeta.meta_key = '_order_total'"; 706 707 $query .= " GROUP BY post.post_status "; 708 $query .= " ORDER BY SUM(postmeta.meta_value) DESC"; 709 } 710 508 711 509 712 $results = $wpdb->get_results( $query); 510 //$this->print_array($results);713 511 714 ?> 512 715 <style> … … 589 792 function ni_woocommerce_sales_statistics_widget(){ 590 793 global $wpdb; 591 $query = " SELECT 592 max(posts.post_date) as order_date 593 594 FROM {$wpdb->prefix}posts as posts "; 595 596 $query .= " WHERE 1=1 "; 597 $query .= " AND posts.post_type = 'shop_order'"; 598 $query .= " AND posts.post_status NOT IN ('auto-draft')"; 599 600 $query .= "order by posts.post_date DESC"; 794 $query = ""; 795 $query .= " SELECT "; 796 if ( $this->is_hpos_enable){ 797 $query .= "max(posts.date_created_gmt) as order_date "; 798 799 $query .= "FROM {$wpdb->prefix}wc_orders as posts "; 800 801 $query .= " WHERE 1=1 "; 802 $query .= " AND posts.type = 'shop_order'"; 803 $query .= " AND posts.status NOT IN ('auto-draft')"; 804 805 $query .= "order by posts.date_created_gmt DESC"; 806 807 }else{ 808 $query .= "max(posts.post_date) as order_date "; 809 810 $query .= "FROM {$wpdb->prefix}posts as posts "; 811 812 $query .= " WHERE 1=1 "; 813 $query .= " AND posts.post_type = 'shop_order'"; 814 $query .= " AND posts.post_status NOT IN ('auto-draft')"; 815 816 $query .= "order by posts.post_date DESC"; 817 } 818 601 819 602 820 $results = $wpdb->get_var( $query); … … 615 833 } 616 834 function time_elapsed_string($datetime, $full = false) { 617 $now = new DateTime ;835 $now = new DateTime(); 618 836 $ago = new DateTime($datetime); 619 837 $diff = $now->diff($ago); 620 621 $diff->w = floor($diff->d / 7); 622 $diff->d -= $diff->w * 7; 623 838 839 // Calculate the number of weeks and adjust days 840 $weeks = floor($diff->days / 7); 841 $days = $diff->days % 7; 842 624 843 $string = array( 625 844 'y' => 'year', … … 631 850 's' => 'second', 632 851 ); 633 foreach ($string as $k => &$v) { 634 if ($diff->$k) { 635 $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : ''); 636 } else { 637 unset($string[$k]); 852 853 // Create an associative array to hold the time components 854 $result = array( 855 'y' => $diff->y, 856 'm' => $diff->m, 857 'w' => $weeks, 858 'd' => $days, 859 'h' => $diff->h, 860 'i' => $diff->i, 861 's' => $diff->s, 862 ); 863 864 // Build the result string 865 $parts = array(); 866 foreach ($string as $k => $v) { 867 if ($result[$k]) { 868 $parts[] = $result[$k] . ' ' . $v . ($result[$k] > 1 ? 's' : ''); 638 869 } 639 870 } 640 641 if (!$full) $string = array_slice($string, 0, 1); 642 return $string ? implode(', ', $string) . ' ago' : 'just now'; 643 } 871 872 if (!$full) $parts = array_slice($parts, 0, 1); 873 return $parts ? implode(', ', $parts) . ' ago' : 'just now'; 874 } 875 644 876 function ni_woocommerce_new_customer_widget(){ 645 877 $lists['today']['count'] = $daily_count = $this->new_customer('today'); -
ni-woocommerce-dashboard-report/trunk/ni-woocommerce-dashboard-report.php
r3010873 r3138223 3 3 Plugin Name: Ni WooCommerce Dashboard Sales Report 4 4 Plugin URI: http://naziinfotech.com/ 5 Description: Enhance your WooCommerce store 's performance with the "Ni WooCommerce Dashboard Report" plugin. Gain valuable insights, track sales, and optimize your online business for success.6 Version: 2.2. 85 Description: Enhance your WooCommerce store with the "Ni WooCommerce Dashboard Report" plugin. Gain insights, track sales, and optimize your business. 6 Version: 2.2.9 7 7 Author: anzia 8 8 Author URI: http://naziinfotech.com/ … … 13 13 Domain Path: /languages/ 14 14 Requires at least: 4.7 15 Tested up to: 6. 4.215 Tested up to: 6.6.1 16 16 WC requires at least: 3.0.0 17 WC tested up to: 8.4.018 Last Updated Date: 17-December-202317 WC tested up to: 9.1.4 18 Last Updated Date: 20-August-2024 19 19 Requires PHP: 7.0 20 */ 21 if ( ! defined( 'ABSPATH' ) ) { exit;} 22 if(!class_exists('NiWooDR_Dashbaord_Report')){ 23 class NiWooDR_Dashbaord_Report{ 24 public function __construct(){ 25 add_action('plugins_loaded', array($this, 'plugins_loaded')); 26 add_action( 'before_woocommerce_init', array(&$this,'before_woocommerce_init') ); 27 } 28 function before_woocommerce_init(){ 29 if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) { 30 \Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true ); 31 } 32 } 33 function plugins_loaded(){ 34 35 load_plugin_textdomain('nidashboardreport', WP_PLUGIN_DIR.'/ni-woocommerce-dashboard-report/languages','ni-woocommerce-dashboard-report/languages'); 36 include_once('include/ni-dashboard-report.php'); 37 $obj = new ni_dashboard_report(); 38 } 20 39 21 */ 22 include_once('include/ni-dashboard-report.php'); 23 $obj = new ni_dashboard_report(); 24 function plugins_loaded(){ 25 load_plugin_textdomain('nidashboardreport', WP_PLUGIN_DIR.'/ni-woocommerce-dashboard-report/languages','ni-woocommerce-dashboard-report/languages'); 26 //load_plugin_textdomain('nipepro', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 40 } 41 27 42 } 28 add_action( 'plugins_loaded', 'plugins_loaded');43 $obj = new NiWooDR_Dashbaord_Report(); -
ni-woocommerce-dashboard-report/trunk/readme.txt
r3010873 r3138223 1 1 === Ni WooCommerce Dashboard Sales Report === 2 2 Contributors: anzia 3 Tags: report, sales, order,customer, sales report, order report, woocommerce reports, new customer4 Stable tag: 2.2. 83 Tags: dashboard report, order status report, sales report, customer report 4 Stable tag: 2.2.9 5 5 License: GPLv3 or later 6 6 License URI: http://www.gnu.org/licenses/agpl-3.0.html … … 8 8 Plugin URI: https://wordpress.org/plugins/ni-woocommerce-dashboard-report/ 9 9 Requires at least: 4.7 10 Tested up to: 6. 4.210 Tested up to: 6.6.1 11 11 WC requires at least: 3.0.0 12 WC tested up to: 8.4.013 Last Updated Date: 17-December-202312 WC tested up to: 9.1.4 13 Last Updated Date:20-August-2024 14 14 Requires PHP: 7.0 15 15 16 16 17 Enhance your WooCommerce store 's performance with the "Ni WooCommerce Dashboard Report" plugin. Gain valuable insights, track sales, and optimize your online business for success. Download now!17 Enhance your WooCommerce store with the "Ni WooCommerce Dashboard Report" plugin. Gain insights, track sales, and optimize your business. 18 18 19 19 == Description == … … 83 83 </blockquote> 84 84 85 85 <p> 86 <strong>Note</strong>: This plugin is fully compatible with both WooCommerce's new High-Performance Order Storage (HPOS) and the legacy WordPress posts storage. Whether you are utilizing HPOS or the traditional storage method, you can rely on this plugin to work seamlessly with your current setup. 87 </p> 86 88 87 89 <blockquote> … … 94 96 </blockquote> 95 97 98 96 99 Feedback 97 100 * We are open to your suggestions and feedback - Thank you for using or trying out one of our plugins. … … 129 132 == Changelog == 130 133 134 = version 2.2.9 -20-August-2024 = 135 * Tested: Compatible With WooCommerce 9.1.4 136 * Tested: Compatible With WordPress 6.6.1 137 * Tested: High-Performance Order Storage (HPOS) 138 131 139 = version 2.2.8 -17-December-2023 = 132 140 * Tested: Compatible With WooCommerce 8.4.0
Note: See TracChangeset
for help on using the changeset viewer.