Support order search by transaction_id natively (#46129)

This commit is contained in:
Francesco Carlucci 2024-04-09 08:57:36 +02:00 committed by GitHub
parent 5bb308f486
commit 98ab2f81d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: update
Add order search by transaction_id

View File

@ -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',