Order is search with the phone number and linked with the user accoun… (#37844)

* Order is search with the phone number and linked with the user account. #36810

* updated the query and tested on local env

* fixed the phpcs issue

* added the changelog

* updated the string concatenation issue and also moved the change log file to the correct path

* removed the %i placeholder from the query and used the old way to add the table name
This commit is contained in:
Ali Shan 2023-04-28 20:11:58 +05:00 committed by GitHub
parent f3959d0700
commit 255d5f377c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: enhancement
Order is search with the phone number and linked with the customer/user account.

View File

@ -538,7 +538,7 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
$unpaid_orders = $wpdb->get_col(
$wpdb->prepare(
// @codingStandardsIgnoreStart
// @codingStandardsIgnoreStart
"SELECT posts.ID
FROM {$wpdb->posts} AS posts
WHERE posts.post_type IN ('" . implode( "','", wc_get_order_types() ) . "')
@ -577,6 +577,7 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
'_shipping_address_index',
'_billing_last_name',
'_billing_email',
'_billing_phone',
)
)
);
@ -603,6 +604,16 @@ class WC_Order_Data_Store_CPT extends Abstract_WC_Order_Data_Store_CPT implement
WHERE order_item_name LIKE %s",
'%' . $wpdb->esc_like( wc_clean( $term ) ) . '%'
)
),
$wpdb->get_col(
$wpdb->prepare(
"SELECT DISTINCT os.order_id FROM {$wpdb->prefix}wc_order_stats os
INNER JOIN {$wpdb->prefix}wc_customer_lookup cl ON os.customer_id = cl.customer_id
INNER JOIN {$wpdb->usermeta} um ON cl.user_id = um.user_id
WHERE (um.meta_key = 'billing_phone' OR um.meta_key = 'shipping_phone')
AND um.meta_value = %s",
wc_clean( $term )
)
)
)
);