Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Created May 14, 2020 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pebblo/d2b24f3a8a8713146e495c3a9cc2e3e1 to your computer and use it in GitHub Desktop.
Save Pebblo/d2b24f3a8a8713146e495c3a9cc2e3e1 to your computer and use it in GitHub Desktop.
Example of how to use jQuery to set the defautl value of the EE State dropdown. Change val(45) to the ID of the state you wish to use.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
function tw_ee_default_state_option(){
wp_add_inline_script(
'single_page_checkout',
"jQuery(document).ready(function($){
$('select.ee-reg-qstn-state').val(45).prop('selected', true);
});"
);
}
add_action( 'wp_enqueue_scripts', 'tw_ee_default_state_option', 50 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment