Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created April 14, 2020 19:24
Show Gist options
  • Save joshfeck/caaacef4587ba906ec414f6f2120f634 to your computer and use it in GitHub Desktop.
Save joshfeck/caaacef4587ba906ec414f6f2120f634 to your computer and use it in GitHub Desktop.
Auto-fill County in billing form for Stripe. Event Espresso 4
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
// remove "add new state microform" from billing form
add_action(
'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons',
function() {
remove_filter(
'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form',
array(
'EED_Add_New_State',
'display_add_new_state_micro_form'
),
1,
1
);
},
11
);
// pre-select "Canada" in Billing Form's Country input
add_filter(
'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee',
'my_billing_form_autofill_country',
10,
2
);
function my_billing_form_autofill_country(
$autofill_data,
$attendee
) {
$autofill_data[ 'country' ] = 'CA';
return $autofill_data;
}
// remove all other country options from Billing Form's Country input
add_action(
'wp_enqueue_scripts',
'my_lock_billing_country_field',
20
);
function my_lock_billing_country_field(){
$custom_js = 'jQuery(document).bind("ready ajaxComplete", (function(){';
$custom_js .= 'jQuery("#stripe-payment-intent-and-elements-form-country option:not(:selected)").remove();';
$custom_js .= '}));';
wp_add_inline_script('ee_form_section_validation', $custom_js);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment