Support order search by transaction_id natively (#46129)
This commit is contained in:
parent
5bb308f486
commit
98ab2f81d6
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: update
|
||||
|
||||
Add order search by transaction_id
|
|
@ -54,6 +54,7 @@ class OrdersTableSearchQuery {
|
|||
private function sanitize_search_filters( string $search_filter ) : array {
|
||||
$core_filters = array(
|
||||
'order_id',
|
||||
'transaction_id',
|
||||
'customer_email',
|
||||
'customers', // customers also searches in meta.
|
||||
'products',
|
||||
|
@ -199,6 +200,13 @@ class OrdersTableSearchQuery {
|
|||
);
|
||||
}
|
||||
|
||||
if ( 'transaction_id' === $search_filter ) {
|
||||
return $wpdb->prepare(
|
||||
"`$order_table`.transaction_id LIKE %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- $order_table is hardcoded.
|
||||
'%' . $wpdb->esc_like( $this->search_term ) . '%'
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'products' === $search_filter ) {
|
||||
return $wpdb->prepare(
|
||||
'search_query_items.order_item_name LIKE %s',
|
||||
|
|
Loading…
Reference in New Issue