Support

Home Forums Event Espresso Premium Default Country not selected in Payment Options

Default Country not selected in Payment Options

Posted: August 9, 2016 at 2:03 am

Viewing 2 reply threads


Oguzhan Altun

August 9, 2016 at 2:03 am

Hello,

Following this thread, I just realized that after we fixed the automatic country selection in the Attendee Information (which comes out correctly as Switzerland selected), the country field in the payment options screen now comes up empty. You can test this at any of the events, for example this one.

I would also like to hide the “State” field in the Payment Options screen, can I do that with custom css? How?

Here is the existing code related to this in my site specific plugin:

//* Prefill country with Switzerland in the registration form

function ee_add_javascript_registration_checkout_default_country() {
    if ( is_page( 'registration-checkout' ) ) {
        ?>
    <script>
        jQuery(document).ready( function($) {
          jQuery("select[id$=country]").val("CH");
        });
        </script>
        <?php
    }
}
add_action( 'wp_head', 'ee_add_javascript_registration_checkout_default_country' );

//* Allow state or province field to be a text field and make it optional
add_filter( 'FHEE__EE_Billing_Attendee_Info_Form__state_field', 'billing_locale_text_field', 10, 1 );
//add_filter( 'FHEE__EE_Billing_Attendee_Info_Form__country_field', 'billing_locale_text_field', 10, 1 );
function billing_locale_text_field( $original_field ) {
    return new EE_Text_Input( array( 'required' => false, 'html_class' => 'ee-billing-qstn'));
}

function ee_populate_from_attendee_information_or_use_default( $autofill_data, $attendee ) {
    if( $attendee instanceof EE_Attendee) {
        if( $attendee->state_ID() ) {
            $autofill_data[ 'state' ] = $attendee->state_name();
        } else { 
            $autofill_data[ 'state' ] = '';
        }
        if( $attendee->country_ID() ) {
            $autofill_data[ 'country' ] = $attendee->country_name();
        } else { 
            $autofill_data[ 'country' ] = 'CH';
        }
    }
    return $autofill_data;
}
add_filter( 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', 'ee_populate_from_attendee_information_or_use_default', 10, 2 );


Josh

  • Support Staff

August 12, 2016 at 8:32 am

You can probably remove the part where you have the ee_populate_from_attendee_information_or_use_default() function and its accompanying filter hook. This is because state and country values are automatically autofilled from what’s selected on the reg form. If you decide that you want to leave that code in, you can change the part where it has this:

$autofill_data[ 'country' ] = $attendee->country_name();

to this:

return $autofill_data;

I would also like to hide the “State” field in the Payment Options screen, can I do that with custom css? How?

This is not recommended since it could result in failed credit card verifications, but that’s ultimately your call, so you’d add this to your stylesheet:

#eea-braintree-billing-form-state-input-dv{ display:none;}


Oguzhan Altun

August 12, 2016 at 8:50 am

ok this worked perfectly. thank you!

Viewing 2 reply threads

The support post ‘Default Country not selected in Payment Options’ 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