Support

Home Forums Event Espresso Premium State Dropdown on Apple Mobile Devices

State Dropdown on Apple Mobile Devices

Posted: April 24, 2023 at 3:25 pm

Viewing 9 reply threads


mkreik

April 24, 2023 at 3:25 pm

I’ve reached out about this issue each year to see if you have found a solution to the fact that when using a Apple device and choosing the country, it does not show only the states for that country. Have you found a solution? Is there a way to set a default country and state? That would help for our local customers who have to scroll through hundreds of states before they get to the US states at the bottom of the list. I have looked for a setting to set defaults for state and country and have not found any.


Tony

  • Support Staff

June 1, 2023 at 2:04 pm

Hi there,

My apologies for missing this thread previously.

The only way we to set the default country currently is using a custom snippet to do it via JS, something like this:

https://gist.github.com/Pebblo/f6d51d80506130c1a5780f49b9cb3c14

You ‘can’ also set a default state from within that code if required but try adding the above to a custom functions plugin first to see it works for you as is.

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/


mkreik

June 1, 2023 at 2:58 pm

Thanks. I will look into those.


mkreik

June 2, 2023 at 1:31 pm

I’m not comfortable creating a plugin so I thought I would add the script to the child theme for the website in the functions.php file. I first added the script to make US the country default, and it worked. I then modified the country script to use for the default state, Illinois, and tried the val to “IL” and “Illinois” but that didn’t work. I’m assuming I need to modify the code further but don’t know where. Any insight? Here’s what I tried for the default state:

add_action(
‘wp_enqueue_scripts’,
‘tw_ee_change_default_ee_state_option’,
20
);
function tw_ee_change_default_ee_state_option(){
$custom_js = ‘jQuery(document).ready(function($){‘;
$custom_js .= ‘$(“.ee-reg-qstn-state”).val(“IL”).trigger(“change”);’;
$custom_js .= ‘});’;
wp_add_inline_script(‘ee_form_section_validation’, $custom_js);
}


Tony

  • Support Staff

June 5, 2023 at 5:02 am

For state you’ll need the ID, can you link me to an event I can run a test registration on to view the form?


mkreik

June 5, 2023 at 10:39 am

Yes, I will put a link to an event in a private reply.


mkreik

June 5, 2023 at 10:50 am

This reply has been marked as private.


Tony

  • Support Staff

June 5, 2023 at 1:29 pm

Thats the registration ID and is unique for each registration.

You need the ID of the state, so this:

https://monosnap.com/file/KwNF5Kkhy3LOqBsJQvY5HfX7L2DqeV

I’ve added another snippet to that gist here:

https://gist.github.com/Pebblo/f6d51d80506130c1a5780f49b9cb3c14#file-tw_ee_change_default_ee_country_and_state_option-php

That new gist sets both the country and state.


mkreik

June 5, 2023 at 2:10 pm

That worked! Thank you!


Tony

  • Support Staff

June 5, 2023 at 2:58 pm

You’re most welcome.

Viewing 9 reply threads

The support post ‘State Dropdown on Apple Mobile Devices’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso