Is it possible though installing one of the customer modules so that in admin - customers its possible to search for a customer called David Smith so search for both First and last names.
Currently nothing is found as I understand that's the way that the search works. The only way I can find how to do this is to use the search feature in admin to either find all David's, or all Smith's, and then use the browser search to find the other part within that search.
We can already search email addresses and postcodes, but we want to be able to quickly find customers by name.
Search customers by firstname and lastname
- Mort_Lemur
- Builder
- Posts: 63
- Joined: Tue Jun 02, 2026 6:12 pm
- Phoenix Version: v1.1.0.6
- Has thanked: 42 times
- Been thanked: 17 times
Re: Search customers by firstname and lastname
Hi Steve,
Might be overkill for what you are looking for but AOM gives that functionality.
Might be overkill for what you are looking for but AOM gives that functionality.
- burt
- Core Team
- Posts: 4550
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Search customers by firstname and lastname
Search: David
gives a list of all customers who have David in firstname/lastname and whatever other modules are being searched
Search: Smith
ditto
But "David Smith" won't ever be a match *unless* you have someone called (eg) Oliver David-Smith or somesuch name. IE both David and Smith need to be in the firstname or the lastname.
--
The answer is relatively simple.
Copy
/includes/system/version/1.01.00.00/query.php
to
/includes/system/override/query.php
In that new file amend the function add_search_criteria to split the input key (what you insert into the search box) by space (ie make it see multiple words). Then loop through the split and write the SQL.
Is that enough to go to your favourite AI and get the answer? If not, let me know.
gives a list of all customers who have David in firstname/lastname and whatever other modules are being searched
Search: Smith
ditto
But "David Smith" won't ever be a match *unless* you have someone called (eg) Oliver David-Smith or somesuch name. IE both David and Smith need to be in the firstname or the lastname.
--
The answer is relatively simple.
Copy
/includes/system/version/1.01.00.00/query.php
to
/includes/system/override/query.php
In that new file amend the function add_search_criteria to split the input key (what you insert into the search box) by space (ie make it see multiple words). Then loop through the split and write the SQL.
Is that enough to go to your favourite AI and get the answer? If not, let me know.
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
-
14Steve14
- Senior Contributor
- Posts: 921
- Joined: Fri Oct 25, 2019 7:01 pm
- Phoenix Version: v1.0.9.1
- Has thanked: 17 times
- Been thanked: 103 times
Re: Search customers by firstname and lastname
Thanks Gary for pointing me in the right direction.
One small change and seems to work but with a few odd quirks, but nothing serious. As we have searching set in Postcode, Town, Phone and email it gives some funny results but its better than what it was doing and can find something like David Smith amongst thousands of customers.
Also found a similar file in my live site and made a similar change in there and it now searched fist and last name on my live site. Win win all round.
One small change and seems to work but with a few odd quirks, but nothing serious. As we have searching set in Postcode, Town, Phone and email it gives some funny results but its better than what it was doing and can find something like David Smith amongst thousands of customers.
Also found a similar file in my live site and made a similar change in there and it now searched fist and last name on my live site. Win win all round.