Jump to content
You're invited! Join our 4.6 Live Event on ZOOM 6/24 ×

Community

How to remove unnecesarry countries in Commerce?


Maxxius
 Share

Recommended Posts

I affraid you can't change it only in the Commerce. It using Geolocation from System:

	/**
	 * Get Value
	 *
	 * @return	mixed
	 */
	public function formatValue()
	{
		if ( \is_array( $this->value ) )
		{
			$value = array();
			foreach ( $this->value as $k => $v )
			{
				if ( \in_array( (string) $k, \IPS\GeoLocation::$countries ) )
				{
					$value[ $k ] = $v;
				}

So if you want to change that you need to write a plugin and modify this class:

namespace IPS;


/**
 * GeoLocation
 */
class _GeoLocation
{

 

Link to comment
Share on other sites

On three different installations with last version of IPS with the same browser I have two different defaults.

  1. No default at all, I have to select country.
  2. Default country is Russia, although I am not in Russia and the project does not even have Russian language installed. It is purely German 😏

My browser language according to the link above is DE. However I have additional languages configured in Chrome and this tool says:

Your browser's Accept-Language header:
de,ru-RU;q=0.9,ru;q=0.8,en-DE;q=0.7,en-US;q=0.6,en;q=0.5

Something is wrong with this automatic detection. And this is not only browser language and location but also the installation that shows different behaviour.

 

Link to comment
Share on other sites

On 2/13/2020 at 8:24 AM, Maxxius said:

Or at least choose a default selected country.

I wish this as well as setting in ACP. It is not really helpful to rely on browser language to detect location. Even if I use English in my browser as primary language it does not automatically mean I am placed in USA. 😉

Link to comment
Share on other sites

9 hours ago, Maxxius said:

@Mark

ohh..

I'm in lithuania, yeah language says en, because I like browser to be in english version. no VPN ever.

Just "en", not "en-[something]"? If that's the case it shouldn't default to anything...

What does this tool say? Which OS and browser?

6 hours ago, Sonya* said:

On three different installations with last version of IPS with the same browser I have two different defaults.

  1. No default at all, I have to select country.
  2. Default country is Russia, although I am not in Russia and the project does not even have Russian language installed. It is purely German 😏

My browser language according to the link above is DE. However I have additional languages configured in Chrome and this tool says:


Your browser's Accept-Language header:
de,ru-RU;q=0.9,ru;q=0.8,en-DE;q=0.7,en-US;q=0.6,en;q=0.5

Something is wrong with this automatic detection. And this is not only browser language and location but also the installation that shows different behaviour.

Ah, I see the issue with that one. I'll fix that for the next version.

Link to comment
Share on other sites

On 2/13/2020 at 1:15 PM, Mark said:

It should default to your own country.

  1. Which country are you in?
  2. If you go here: https://www.whatsmybrowser.org - what does it show for "Language"?
  3. Are you using a VPN?

Your browser's Accept-Language header:
en-US,en;q=0.5

whatsmybrowser.org/b/YY7R5KR

I have made the test results here.

Thing is I indeed do have my browser in english, I dont like my language translations of software. But why does this mechanism not take into account the ip address or country where I am. I bet millions of people use browsers in english and not in native language.

Link to comment
Share on other sites

9 hours ago, Mark said:

One would expect it to be "en-XX" where "XX" is your country code.

This is not the case for me, if I am in Russia. I still use German or English language in browser while staying in Russia. The best solution for location (Calendar and Commerce) is a hook through IP 

 This way I can use any language in my browser, but default is the country where I am physically placed right now.

For me, working with different languages from different locations were two-way setting the most logical:

  1. Default the country using user IP.
  2. If no country can be found this way, use a country set in ACP by administrator.
Link to comment
Share on other sites

9 hours ago, Mark said:

One would expect it to be "en-XX" where "XX" is your country code. Like in Sonya's example it has en-DE before en-US.

So I can look into it further can you tell me: What country are you in? What OS are you using? What browser are you using?

I'm in lithuania, Windows 10, Firefox latest.

Link to comment
Share on other sites

4 hours ago, Sonya* said:

This is not the case for me, if I am in Russia. I still use German or English language in browser while staying in Russia. The best solution for location (Calendar and Commerce) is a hook through IP 

 This way I can use any language in my browser, but default is the country where I am physically placed right now.

For me, working with different languages from different locations were two-way setting the most logical:

  1. Default the country using user IP.
  2. If no country can be found this way, use a country set in ACP by administrator.

Your browser's header is:

de,ru-RU;q=0.9,ru;q=0.8,en-DE;q=0.7,en-US;q=0.6,en;q=0.5

Which means:

  • I prefer German - I'm not fussy about the region
  • If you can't do that, give me the Russian - I prefer the Russian they use in Russia but will accept Russian from any region
  • If you can't do that, give me English - if you can, format it like I'm in Germany, otherwise United States English is okay, or English from any other region will do

As you can see: this is pretty detailed information, and usually it can be inferred from that information where the user is. It is normally much more reliable than using Geocoding from an IP address which will be wrong if the user is using a VPN, and will change if the user is travelling which is usually undesired. The Accept-Language header is literally for the browser to advise the server of the user's language and region so it's normally well implemented.

In your case, there was a bug, which I've fixed. In Maxxius's case, for some reason it is much more brief - it says "I want English - ideally US English but if not, any English will do". That's why I asked what OS and browser: I will try to reproduce the setup to see what controls the value of the header in that circumstance. Different browsers do different things and sometimes browsers send supplementary information in other headers.

Link to comment
Share on other sites

35 minutes ago, Mark said:

I prefer German

Right. I prefer German, but it is not said that I am in Germany now. I can be in Switzerland, Russia or Kenia. Example: I prefer English (US) being located in UK (my little dirty secret 😎).  For me it is only about language but not the location. Another example: I prefer Russian being located in Germany because my German is not good enough. And so on...

Edited by Sonya*
Link to comment
Share on other sites

Yes, but even if you are in the UK while travelling you wouldn't typically want to use a UK address on most forms. For instance, if you are checking out in the store and have to enter the address associated with your credit card, that's going to be your home address.

Ultimately, we can only guess the country in terms of selecting a default. There is a dropdown with all countries available for a reason. No matter which route we go, there are going to be plenty of use cases where an argument could be made "you should do it this way" or "you should do it that way" and we can't do both at the same time. Running an IP address geolocation check every time a form with an address helper is loaded uses a lot more resources than just inferring the country from the language you are using (which, let's be honest, 99% of people do not change and the language/region accurately reflects where they are located).

Link to comment
Share on other sites

Interesting read. However I wish simply that there was some sort of override setting that allows us to make the choices that are above the autodetection mechanism. for example if I'm running a local business, like local in the means of it being only in my country and I don't ship outside of my country. I truly wish to make the default language of address selected as I command and even remove the country list at all, and even remove the region field because as in my country it is not vital information when shipping anything. I'd like to make it as simple as possible for the buyers.

also on another note why not make an ability to limit shipping options depending on the payment method. I made a topic about it yesterday in feedback forum.

Link to comment
Share on other sites

On 2/21/2020 at 12:24 AM, Sonya* said:

Right. I prefer German, but it is not said that I am in Germany now. I can be in Switzerland, Russia or Kenia. Example: I prefer English (US) being located in UK (my little dirty secret 😎).  For me it is only about language but not the location. Another example: I prefer Russian being located in Germany because my German is not good enough. And so on...

Wait, so where do you live? The UK? Or Germany?

Link to comment
Share on other sites

Just now, Mark
On 2/21/2020 at 12:24 AM, Sonya* said:

Right. I prefer German, but it is not said that I am in Germany now. I can be in Switzerland, Russia or Kenia. Example: I prefer English (US) being located in UK (my little dirty secret 😎).  For me it is only about language but not the location. Another example: I prefer Russian being located in Germany because my German is not good enough. And so on...

Wait, so where do you live? The UK? Or Germany?

These were just examples. I am the most time in Germany, preferring English in my browser due to my job 😊

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...

Important Information

We use technologies, such as cookies, to customise content and advertising, to provide social media features and to analyse traffic to the site. We also share information about your use of our site with our trusted social media, advertising and analytics partners. See more about cookies and our Privacy Policy