Support

Home Forums Event Espresso Premium limiting certain countries from registration

limiting certain countries from registration

Posted: September 2, 2020 at 4:26 pm


Kerry@novalda.com

September 2, 2020 at 4:26 pm

Hello, you gave me some code earlier to make a plugin which limits everyone who isn’t from Canada to register. (https://eventespresso.com/topic/how-to-limit-payment-by-country-but-still-register/)

She would now like to change that code to stop people from a group of countries to register (instead of just allowing Canada). Is it possible to get some code to do that instead? The locations are: USA, Africa, UK, Mexico, Singapore, Australia, New Zealand, UAE, Israel, Japan, Philipines, Malaysia, China, Spain, The Netherlands, France, Norwar, Denmark, Germany, Turkey and Switzerland. People from all other countries can register as normal. I’m not sure if this would be included in the regular support, but she is OK to pay for the coding if there is a fee. I’d love to be able to edit the code later if I needed to add or remove countries as well.

Thanks for your help!


Tony

  • Support Staff

September 10, 2020 at 9:11 am

Hi there,

Do you currently collect the address questions on the registration form at all? (Other than the payment step)

The reason I’m asking is one option is to tie the countries shown on the Stripe country select, if those are different than what you want on the registration form (I can’t imagine why they would be) then it wont work but it gives you the option to enable and disable countries as needed.


Tony

  • Support Staff

September 10, 2020 at 11:42 am

I realised I did a really poor job of explaining this above so I’ll add some additional info here.

Within Event Espresso we have a section that allows you to control the ‘Countries’ shown on your site, that’s in:

Event Espresso -> General Settings -> Countries.

You can set specific countries to show in any ‘country’ dropdown lists on your site in that section… however, the payment forms ignore those settings by default and pull them all (the reason being so that users can still set the correct billing country even if the admin hasn’t enabled it).

So the Stripe payment method loads them all, and Josh gave you a snippet to basically remove all but Canada again.

So, rather than trying to work through a bunch of exclusions for that specific dropdown etc, would it work if the Stripe payment form used whichever countries were enabled in your settings?

It means you can control which countries show at any time without additional code, but…..

The countries in that section are using everywhere else within EE, so if you only want to limit the Stripe payment method country list, the above wont work.

If you want different countries available for selection on the registration form vs the payment form, the above wont work.

If you don’t collect address info on the Registration form, then it’s likely the best part to take so that you don’t need additional code later on and you can always switch it out again should you need to.


Kerry@novalda.com

September 14, 2020 at 11:21 am

Thank you – I’ll try to figure this out today. Sounds like a good option.


Kerry@novalda.com

September 14, 2020 at 11:35 am

Question – if I go in and turn on all the countries I want to include, and just click ‘no’ on the ones that we are not including, then how do I get the payment form to go by those settings and not just pull them all in as you mentioned above?

And is it possible to have one payment method include any country (going to one stripe account) and another to have this country limitation set in the general settings and go to another stripe account?


Kerry@novalda.com

September 14, 2020 at 12:41 pm

Hi again, sorry for all the questions. I am turning all the countries on one by one in the settings > countries sections. But I’ve still got this plugin turned on for one of the payment methods that limits to Canada. Will that mess things up? I’m not sure if I should disable it and just replace with this new method. Also, there’s red text on each of the county pages saying “the Currency setting inputs are currently only enabled for the country “Canada” which is the selected country for the site. This can be changed in the “Contact Information” section under the “Your Organization” tab of the Event Espresso – General Settings.” But I would just leave that set to Canada, wouldn’t I, with Canadian $$ as the currency for any transaction?


Tony

  • Support Staff

September 14, 2020 at 1:11 pm

Question – if I go in and turn on all the countries I want to include, and just click ‘no’ on the ones that we are not including, then how do I get the payment form to go by those settings and not just pull them all in as you mentioned above?

You’ll need some code for this, it doesn’t do it by default but before I started looking into the code I wanted to check if it was something that would work for you.

And is it possible to have one payment method include any country (going to one stripe account) and another to have this country limitation set in the general settings and go to another stripe account?

Yes, this should be possible.

Hi again, sorry for all the questions. I am turning all the countries on one by one in the settings > countries sections.

There’s a plugin that can enable them all for you here:

https://eventespresso.com/topic/enabling-all-countries-in-settings/#post-281184

But I’ve still got this plugin turned on for one of the payment methods that limits to Canada. Will that mess things up? I’m not sure if I should disable it and just replace with this new method.

Leaving it enabled until you are ready to switch over shouldn’t break anything but I recommend adding a test registration to confirm.

Also, there’s red text on each of the county pages saying “the Currency setting inputs are currently only enabled for the country “Canada” which is the selected country for the site. This can be changed in the “Contact Information” section under the “Your Organization” tab of the Event Espresso – General Settings.” But I would just leave that set to Canada, wouldn’t I, with Canadian $$ as the currency for any transaction?

That text is basically saying, ‘Because your site is set to Canada, we don’t allow you to change the currency settings for this country’.

The reason being is that users started editing the countries section settings trying to change their own currency settings rather than changing them specifically for the country they had set.


Kerry@novalda.com

September 14, 2020 at 2:00 pm

Hi again,

I’ve turned on most of the ones we need (and can change them later if needed) so if we need code in order to use it, please do send that. Does this work by making it into a plugin? (maybe I could just replace the old plugin code with this new code?). Do I set up a payment method to use with this specific set of countries?

Then I will leave my other two payment methods (any country, and one to a different stripe account) and that should work, correct?

Thanks for all your help – it always amazes me how much we can accomplish with EE.


Tony

  • Support Staff

September 16, 2020 at 3:39 am

I’ve turned on most of the ones we need (and can change them later if needed) so if we need code in order to use it, please do send that.

To force Stripe’s billing form to output only active countries on your install you can use something like this:

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

Does this work by making it into a plugin?

Yes, you can add that code in a plugin, or at the end of the plugin Josh gave you.

(maybe I could just replace the old plugin code with this new code?).

You’re request changed a little when you asked to do both limit the countries for specific payment methods and allow for this setup, so you likely need this new code and Josh’s.

Try with both active and see if it works for you.

Do I set up a payment method to use with this specific set of countries?

Right now this should filter all Stripe payment methods to use those countries.

Then I will leave my other two payment methods (any country, and one to a different stripe account) and that should work, correct?

Sorry but I don’t follow this bit, how many payment methods do you have?


Kerry@novalda.com

September 17, 2020 at 5:52 pm

Hi, thanks again for this. I have the old code, which tells it to remove all other country options, and then this new code tells it to use the selections I’ve added under Countries – won’t the first function cancel out the second? I’m not a coder, so apart from adding the php code in as a plugin I don’t know how to edit it to make it work.

We don’t necessarily need the first code if we can use the second code though, because we only really need to make sure we’re not selling to the countries that are turned off in the countries settings and don’t need it to check for Canada only anymore, so presumably I can just use the new code.

However, I do need another payment method that doesn’t do this and lets people from any country register. I am unsure how I am linking to this plugin from a specific payment method though. Can I have another payment method that doesn’t limit the countries showing in the dropdown, or will this plugin code apply to everything?

thanks again!


Kerry@novalda.com

September 17, 2020 at 7:34 pm

Hi again,
I tried the code and it does work, but it applies it to all of our payments so we can’t use it as is. Is it possible to leave it open to any location on a separate payment method if we don’t have the collect user’s billing address on?

And if that did work, could we collect the address info in the registration area still by just adding our own fields to the top registration section instead of using the regular address section?

Just to clarify – we need a payment method limited to certain countries, and another payment method that isn’t limited, based on which course it is.


Kerry@novalda.com

September 30, 2020 at 2:56 pm

Hi again, any updates to this question? I need to limit one payment method using the countries but not all of them. Can I get around this by not asking the address question on registration for the payments that we don’t want the limiting on? thanks!


Tony

  • Support Staff

October 2, 2020 at 4:14 am

I tried the code and it does work, but it applies it to all of our payments so we can’t use it as is. Is it possible to leave it open to any location on a separate payment method if we don’t have the collect user’s billing address on?

Sure, if you create an instance of the Stripe payment method that has ‘Collect the user’s billing address?’ set to No, then the above snippet wont run on that payment method.

And if that did work, could we collect the address info in the registration area still by just adding our own fields to the top registration section instead of using the regular address section?

The payment method form autofills with the values of the address info given on the registration but they are actually separate, intentionally becuase the payee details could very well be different from the attendees. We autofill using those details by default because that’s the most common use case but the 2 fields are really ‘connected’ in any other way.

That means you if you have a Stripe payment method that doesn’t collect billing info (as above) you can still collect the address information on the registration form without issue.

Just to clarify – we need a payment method limited to certain countries, and another payment method that isn’t limited, based on which course it is.

The code can be adjusted to only target a specific payment method instance, for example, you could have one called ‘Stripe’ and another called ‘Stripe limited’ and then set the above code to only run if the payment method is ‘Stripe limited’.

However, it sounds like you could simply just disable collecting the address info on the Stripe payment method form itself for an ‘unlimited’ Stripe payment method and the code above will limit the others.

So, I can show you how to make this target only a specific payment method or would you like to just disable the billing details on the Stripe form?

The support post ‘limiting certain countries from registration’ 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