Skip to content

Commit 3c1a903

Browse files
Merge pull request #43 from godaddy-wordpress/release/1.11.2
Release: v1.11.2
2 parents 08f01ea + 6fe32e8 commit 3c1a903

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

readme.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ $order_number = $order->get_order_number();
104104

105105
== Changelog ==
106106

107+
= 2025.nn.nn - version 1.11.2-dev.1 =
108+
* Tweak - Add new "Sequential Order Number" option to the search order dropdown
109+
* Fix - Searching by order number not working when Full Text Search is enabled (previous fix did not take full effect)
110+
107111
= 2025.05.07 - version 1.11.1 =
108112
* Fix - Searching by order number not working when Full Text Search is enabled
109113

woocommerce-sequential-order-numbers.php

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
* Description: Provides sequential order numbers for WooCommerce orders
66
* Author: SkyVerge
77
* Author URI: http://www.skyverge.com
8-
* Version: 1.11.1
8+
* Version: 1.11.2-dev.1
99
* Text Domain: woocommerce-sequential-order-numbers
1010
* Domain Path: /i18n/languages/
1111
*
12-
* Copyright: (c) 2012-2023, SkyVerge, Inc. ([email protected])
12+
* Copyright: (c) 2012-2025, SkyVerge, Inc. ([email protected])
1313
*
1414
* License: GNU General Public License v3.0
1515
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
1616
*
1717
* @author SkyVerge
18-
* @copyright Copyright (c) 2012-2023, SkyVerge, Inc. ([email protected])
18+
* @copyright Copyright (c) 2012-2025, SkyVerge, Inc. ([email protected])
1919
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
2020
*
2121
* WC requires at least: 3.9.4
@@ -38,7 +38,7 @@ class WC_Seq_Order_Number {
3838

3939

4040
/** Version number */
41-
public const VERSION = '1.11.1';
41+
public const VERSION = '1.11.2-dev.1';
4242

4343
/** Minimum required wc version */
4444
public const MINIMUM_WC_VERSION = '3.9.4';
@@ -207,6 +207,7 @@ public function initialize() : void {
207207
}
208208

209209
// ensure that admin order table search by order number works
210+
add_filter('woocommerce_hpos_admin_search_filters', [$this, 'addOrderNumberSearchFilter']);
210211
add_filter( 'woocommerce_shop_order_search_fields', [ $this, 'custom_search_fields' ] );
211212
add_filter( 'woocommerce_order_table_search_query_meta_keys', [ $this, 'custom_search_fields' ] );
212213

@@ -464,6 +465,36 @@ public function custom_orderby( array $args ) : array {
464465
return $args;
465466
}
466467

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+
467498

468499
/**
469500
* 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 {
481512
}
482513

483514
/**
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.
487516
*
488517
* @param string|mixed $whereClause
489518
* @param string|mixed $searchTerm
@@ -493,16 +522,11 @@ public function custom_search_fields( array $search_fields ) : array {
493522
*/
494523
public function fullTextSearchFilterWhereClause($whereClause, $searchTerm, $searchFilter, $query)
495524
{
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+
}
505528

529+
try {
506530
global $wpdb;
507531
$order_table = $query->get_table_name('orders');
508532
$meta_table = $query->get_table_name('meta');

0 commit comments

Comments
 (0)