5
5
* Description: Provides sequential order numbers for WooCommerce orders
6
6
* Author: SkyVerge
7
7
* Author URI: http://www.skyverge.com
8
- * Version: 1.11.1
8
+ * Version: 1.11.2-dev. 1
9
9
* Text Domain: woocommerce-sequential-order-numbers
10
10
* Domain Path: /i18n/languages/
11
11
*
12
- * Copyright: (c) 2012-2023 , SkyVerge, Inc. ([email protected] )
12
+ * Copyright: (c) 2012-2025 , SkyVerge, Inc. ([email protected] )
13
13
*
14
14
* License: GNU General Public License v3.0
15
15
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
16
16
*
17
17
* @author SkyVerge
18
- * @copyright Copyright (c) 2012-2023 , SkyVerge, Inc. ([email protected] )
18
+ * @copyright Copyright (c) 2012-2025 , SkyVerge, Inc. ([email protected] )
19
19
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
20
20
*
21
21
* WC requires at least: 3.9.4
@@ -38,7 +38,7 @@ class WC_Seq_Order_Number {
38
38
39
39
40
40
/** Version number */
41
- public const VERSION = '1.11.1 ' ;
41
+ public const VERSION = '1.11.2-dev. 1 ' ;
42
42
43
43
/** Minimum required wc version */
44
44
public const MINIMUM_WC_VERSION = '3.9.4 ' ;
@@ -207,6 +207,7 @@ public function initialize() : void {
207
207
}
208
208
209
209
// ensure that admin order table search by order number works
210
+ add_filter ('woocommerce_hpos_admin_search_filters ' , [$ this , 'addOrderNumberSearchFilter ' ]);
210
211
add_filter ( 'woocommerce_shop_order_search_fields ' , [ $ this , 'custom_search_fields ' ] );
211
212
add_filter ( 'woocommerce_order_table_search_query_meta_keys ' , [ $ this , 'custom_search_fields ' ] );
212
213
@@ -464,6 +465,36 @@ public function custom_orderby( array $args ) : array {
464
465
return $ args ;
465
466
}
466
467
468
+ /**
469
+ * Adds a new search filter option for the sequential order number.
470
+ *
471
+ * @internal
472
+ * @since 1.11.2-dev.1
473
+ *
474
+ * @param array|mixed $options search options
475
+ * @return array|mixed
476
+ */
477
+ public function addOrderNumberSearchFilter ($ options )
478
+ {
479
+ if (! is_array ($ options )) {
480
+ return $ options ;
481
+ }
482
+
483
+ // Insert sequential_order_number after order_id
484
+ $ newOption = ['sequential_order_number ' => __ ('Sequential Order Number ' , 'woocommerce-sequential-order-numbers ' )];
485
+ $ orderIdPosition = array_search ('order_id ' , array_keys ($ options ));
486
+ if ($ orderIdPosition !== false ) {
487
+ $ insertPosition = $ orderIdPosition + 1 ;
488
+ $ options = array_slice ($ options , 0 , $ insertPosition , true ) +
489
+ $ newOption +
490
+ array_slice ($ options , $ insertPosition , null , true );
491
+ } else {
492
+ $ options = array_merge ($ options , $ newOption );
493
+ }
494
+
495
+ return $ options ;
496
+ }
497
+
467
498
468
499
/**
469
500
* Add our custom `_order_number` to the set of search fields so that the admin search functionality is maintained.
@@ -481,9 +512,7 @@ public function custom_search_fields( array $search_fields ) : array {
481
512
}
482
513
483
514
/**
484
- * When Full Text Search is enabled, {@see \Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableSearchQuery::generate_where_for_meta_table()}
485
- * doesn't run, which means our order ID meta field doesn't get searched. This method is responsible for reproducing that
486
- * method specifically when FTS is enabled.
515
+ * Generates a WHERE clause for the sequential order number search filter.
487
516
*
488
517
* @param string|mixed $whereClause
489
518
* @param string|mixed $searchTerm
@@ -493,16 +522,11 @@ public function custom_search_fields( array $search_fields ) : array {
493
522
*/
494
523
public function fullTextSearchFilterWhereClause ($ whereClause , $ searchTerm , $ searchFilter , $ query )
495
524
{
496
- try {
497
- $ ftsIsEnabled = get_option (CustomOrdersTableController::HPOS_FTS_INDEX_OPTION ) === 'yes ' && get_option (CustomOrdersTableController::HPOS_FTS_ORDER_ITEM_INDEX_CREATED_OPTION ) === 'yes ' ;
498
- if (! $ ftsIsEnabled ) {
499
- return $ whereClause ;
500
- }
501
-
502
- if ($ searchFilter !== 'order_id ' ) {
503
- return $ whereClause ;
504
- }
525
+ if ($ searchFilter !== 'sequential_order_number ' ) {
526
+ return $ whereClause ;
527
+ }
505
528
529
+ try {
506
530
global $ wpdb ;
507
531
$ order_table = $ query ->get_table_name ('orders ' );
508
532
$ meta_table = $ query ->get_table_name ('meta ' );
0 commit comments