Pre-sort Suggestion for "Search by City"
-
Hi there, I have a suggestion for the default “Search by City” feature:
If you have many locations in many cities across many states, this function is more or less useless to the customer unless they already knew which cities contained valid locations, as this function currently sorts all cities alphabetically regardless of state.
As of version 3.96, the code in question is in sl-functions.php at line 1979.
$cs_array=$wpdb->get_results("SELECT CONCAT(TRIM(sl_city), ', ', TRIM(sl_state)) as city_state FROM ".SL_TABLE." WHERE sl_city<>'' AND sl_state<>'' AND sl_latitude<>'' AND sl_longitude<>'' GROUP BY city_state ORDER BY city_state ASC ", ARRAY_A);
To presort the list by state and make the feature much more useful by default, a minor change is enough:
from
ORDER BY city_state ASC
to
ORDER BY sl_state ASC, sl_city ASC
If the state field is not filled, it will sort by city.
Thanks!
(edited for formatting)
https://www.ads-software.com/plugins/store-locator/
- The topic ‘Pre-sort Suggestion for "Search by City"’ is closed to new replies.