8manos / wc-city-select

City Select for WooCommerce. Show a dropdown select as the cities input.
https://wordpress.org/plugins/wc-city-select/
33 stars 41 forks source link

Feature Request: "Other" #22

Open Frank-Marion opened 6 years ago

Frank-Marion commented 6 years ago

I don't yet have quite have the skills to add this. City lists can be incomplete, or perhaps have misspellings. It would be useful to have an "other" option that permits the user to enter something not in the select menu.

PS: Thanks for creating this plugin. Saves me a lot of (remaining) hair pulling.

Mantish commented 6 years ago

My guess is that it shouldn't be too difficult, as select2 support something like this: https://select2.org/tagging @Frank-Marion Would you like to try implementing it?

Frank-Marion commented 6 years ago

No, this one is currently beyond my knowledge and abilities, I think. Otherwise, I would have addressed it myself.

tsbohc commented 5 months ago

I won't submit a PR, but will leave this here in case it helps someone.

All you need is to add tags: true here:

https://github.com/8manos/wc-city-select/blob/2b79a1da79cd33c8f47d36f5eeb66531ac9fddbc/assets/js/city-select.js#L64-L67

Like so (note the comma on the previous line):

        var select2_args = $.extend({
          placeholderOption: 'first',
          width: '100%',
          tags: true
        }, getEnhancedSelectFormatString() );

And don't forget to clear your js cache and hard refresh the page (Ctrl+Shift+R).