Support

Home Forums Event Espresso Premium Braintree payments: Select a country by default

Braintree payments: Select a country by default

Posted: March 23, 2016 at 9:29 am

Viewing 12 reply threads


Oguzhan Altun

March 23, 2016 at 9:29 am

Hello,

I have followed this thread to enable all countries in Braintree payments.

I was wondering if there is a possibility to have Switzerland selected as default in the payment screen?

Thanks in advance,


Lorenzo Orlando Caum

  • Support Staff

March 23, 2016 at 10:46 am

Hello,

The payment form which is shown after the registration form in step 2 of registration checkout for paid events will auto-populate the country that the registrant/attendee selects in step 1.

Are you collecting the address question group during your registrations?


Lorenzo


Oguzhan Altun

March 24, 2016 at 1:24 am

Hi,
I don’t collect the address group during the registrations, as I don’t ship anything. Anyway I can make it show Switzerland (and if possible Geneva in the city) by default (as all my trainings are in Geneva)?


Lorenzo Orlando Caum

  • Support Staff

March 24, 2016 at 9:24 am

Hello,

Here is some feedback on accomplishing that.

I would look at where most of your guests are located. For example, if most are in Switzerland, then it could help to default to Switzerland.

See example 2 in this link:

https://gist.github.com/lorenzocaum/0b8f168596912fd8252d


Lorenzo


Oguzhan Altun

March 24, 2016 at 9:45 am

hi,
What is the country code for Switzerland? I tried with CH but it didn’t work.


Lorenzo Orlando Caum

  • Support Staff

March 24, 2016 at 10:48 am

Hi, this uses jQuery to load the default selection. I browsed to your registration checkout page and it was on Switzerland:

http://cl.ly/1B053B1J0W2X


Lorenzo


Oguzhan Altun

March 25, 2016 at 9:03 am

Hi,
I just tried again in an incognito window, and again I see nothing selected for country by default?


Lorenzo Orlando Caum

  • Support Staff

March 25, 2016 at 4:44 pm

Hello, go with the updated example 2 and replace US with CH and that should work.

https://gist.github.com/lorenzocaum/0b8f168596912fd8252d


Lorenzo


Oguzhan Altun

March 26, 2016 at 12:49 pm

Hi,

This is what I have right now in the site specific plugin. Should I replace all of this with example 2?

function ee_add_javascript_registration_checkout_footer_default_country() {
        ?>
    <script>
        jQuery(document).ready( function($) {
          jQuery("select[id$=country]").val("CH");
        });
        </script>
        <?php
}
add_action( 'AHEE__SPCO__reg_form_footer', 'ee_add_javascript_registration_checkout_footer_default_country' );

add_filter( 'FHEE__EE_Billing_Attendee_Info_Form__state_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'));
}
add_filter( 'FHEE__EE_Billing_Attendee_Info_Form__populate_from_attendee', 'billing_autofill_differently', 10, 2 );
function billing_autofill_differently( $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' ] = '';
		}
	}
	return $autofill_data;
}


Lorenzo Orlando Caum

  • Support Staff

March 28, 2016 at 11:17 am

Yes, go ahead and replace what you shared with the updated version and be sure to change US to CH.


Lorenzo


Oguzhan Altun

March 28, 2016 at 12:10 pm

Hi Lorenzo,

I just did it. Now it shows Switzerland as default country, but again it asks for the State as obligatory input:((

Could you make it disappear?

I wish this was designed from scratch with the European users in mind…


Oguzhan Altun

March 28, 2016 at 12:12 pm

there is a link to make people add a state, but this would be really stupid to make people add information that is not required, while we want them to make the payment as painlessly and as quickly as possible…


Lorenzo Orlando Caum

  • Support Staff

March 28, 2016 at 12:24 pm

That is fine. Go with this instead:

https://gist.github.com/anonymous/d7be948afd8ac95e2793

So replace what you currently have with the above.


Lorenzo

Viewing 12 reply threads

The support post ‘Braintree payments: Select a country by default’ 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