diff --git a/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php b/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php index a8982de92ee..eb37f61ce6a 100644 --- a/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php +++ b/plugins/woocommerce/includes/data-stores/class-wc-order-data-store-cpt.php @@ -603,6 +603,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 ) + ) ) ) );