Cities addon: dropdown is most important!

Hello Cs-cart team!
Unfortunately, the cities add-on has problems due to the use of the search and suggestion method that prevent users from completing a quick purchase. And they think that the site has a technical problem, while users make mistakes in typing the city name.

Solution:
The cities are displayed as a drop-down menu with search capability
And if the user does not get any results by typing the city, he can delete the word and select his province and city from the list, respectively.

@CS-Cart_team
Did you see it?!

Hello

The cause is that the city search only matches the beginning of the name. If a customer types a fragment from the middle of the name, they get no suggestions and the field looks broken, even though the site works fine. Making the search match any part of the name fixes most of these cases.

Open: app/addons/cities/func.php, function fn_cities_find_cities().

Step 1. Find this line (around line 208):
$search = trim($params[‘q’]) . ‘%’;

Add this new line right after it:
$search_infix = ‘%’ . trim($params[‘q’]) . ‘%’;

Step 2. A bit lower (around line 239) find this line:
$condition[‘search’] = db_quote(‘AND (rcd.city LIKE ?l OR sd.state LIKE ?l)’, $search, $search);

and change $search to $search_infix in that one line only:
$condition[‘search’] = db_quote(‘AND (rcd.city LIKE ?l OR sd.state LIKE ?l)’, $search_infix, $search_infix);

Not tested

Best regards
Robert

2 Likes

Hello
Thanks a lot for your help!

Hello

You are welcome :slight_smile:

Have a nice day

Best regards
Robert

Thanks for the topic. I’ll pass your feedback to the developers!

1 Like