Page 1 of 1
Search customers by firstname and lastname
Posted: Fri Aug 14, 2026 1:52 pm
by 14Steve14
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.
Re: Search customers by firstname and lastname
Posted: Fri Aug 14, 2026 2:05 pm
by Mort_Lemur
Hi Steve,
Might be overkill for what you are looking for but AOM gives that functionality.
Re: Search customers by firstname and lastname
Posted: Fri Aug 14, 2026 2:23 pm
by burt
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.
Re: Search customers by firstname and lastname
Posted: Fri Aug 14, 2026 3:24 pm
by 14Steve14
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.