Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » ecommerce default country

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

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

Page: 1
Go to End
Author Topic: 3424 Views
  • dawgman
    Avatar
    2 Posts

    ecommerce default country Link to this post

    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

  • Sean
    Avatar
    Forum Moderator
    921 Posts

    Re: ecommerce default country Link to this post

    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

  • dawgman
    Avatar
    2 Posts

    Re: ecommerce default country Link to this post

    Thanks for the quick reply Sean!

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

    Keep up the good work.

  • Briohny
    Avatar
    Community Member
    199 Posts

    Re: ecommerce default country Link to this post

    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.

  • Krato
    Avatar
    Community Member
    7 Posts

    Re: ecommerce default country Link to this post

    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

  • Briohny
    Avatar
    Community Member
    199 Posts

    Re: ecommerce default country Link to this post

    Perfect. Thanks Daniel!

    3424 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.