Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

ecommerce default country


Reply

6 Posts   3498 Views

Avatar
dawgman

16 October 2007 at 12:37pm 2 Posts

first, thanks for a fantastic piece of open source software.

second, after much searching, I am unable to find where the ecommerce module defaults to "new zealand" for the country in the code. I would like to change it, but can't seem to locate where to change it.

thanks in advance

Avatar
Sean

16 October 2007 at 5:15pm Forum Moderator, 921 Posts

Hi there,

Thanks for the kind words.

I believe what you're after is this line of code new DropdownField('Country', 'Country', Geoip::getCountryDropDown(), self::findCountry()). It can be viewed in the source browser at:

http://open.silverstripe.com/browser/modules/ecommerce/trunk/code/EcommerceRole.php

Change your EcommerceRole.php in your site so that the 4th argument to the DropdownField self::findCountry() is removed. This should stop the country dropdown from populating a default country. If there are any other instances of the site where a country is defaulting, just do a search on all ecommerce php files for findCountry() or Geoip::visitor_country( in all files.

Originally this was in place so if you're a member, it used your member's country as the default in the dropdown. Otherwise, if you're not a member, or the country hasn't been set in your member preferences, it attempts to find what country you're from based on IP address.

Hope this helps!

Cheers,
Sean

Avatar
dawgman

16 October 2007 at 11:49pm 2 Posts

Thanks for the quick reply Sean!

I will dig into the code tonight. I appreciate the help.

Keep up the good work.

Avatar
Briohny

24 September 2008 at 9:54pm Community Member, 199 Posts

Hi Sean, Instead of just eliminating the self::findCountry() code is it possible to actually change the default from 'New Zealand' to another country?

Thanks in advance.

Avatar
Krato

4 October 2008 at 6:54am (Last edited: 4 October 2008 6:54am), Community Member, 7 Posts

Briohny,

To change the default country, open sapphire/security/Geoip.php
then put the desired 2 digit country code in line 289

...
      if(substr($address,0,7)=="192.168" || substr($address,0,4)=="127.") {
         // default country updated by Daniel Kratohvil
         $code = "US";   // default country :)
      } else {
...

regards,
Daniel

Avatar
Briohny

7 October 2008 at 1:11am Community Member, 199 Posts

Perfect. Thanks Daniel!