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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

E-Commerce Modules /

Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.

Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba

Remove/Hide Country Field in Checkout

Go to End

9 Posts   2427 Views


Community Member, 31 Posts

25 May 2011 at 2:46am


I am trying remove country DropdownField from the Checkout page. But i am not successful.
I think that the directing files are OrderForm and EcommerceRole.
I try to modify these files, but when i do that I have a BlancPage.

In EcommerceRole.php i try to remove these line:

function getEcommerceFields() {
	$fields = new FieldSet(
		new HeaderField('Fakturační informace', 3),
		new TextField('FirstName', 'Jméno'),
		new TextField('Surname', 'Příjmení'),
		new TextField('HomePhone', 'Telefon'),
		new TextField('MobilePhone', 'Mobil'),
		new TextField('Address', 'Adresa'),
		new TextField('AddressLine2', 'PSČ'),
		new TextField('City', 'Město'),
		new TextField('Country', 'Country', Geoip::getCountryDropDown(), EcommerceRole::findCountry())            <- this line i remove

and also the comma on the line over.

When i do this, the field for Country is not displayed, but when I try to push "Different Shipping address" I have only blanc page. And the same thing in OrderForm.php

Have anybody an idea what to do? How I can remove Country Field?


Community Member, 102 Posts

26 May 2011 at 5:21am

Edited: 26/05/2011 5:21am

First, if you're getting blank pages, you need to switch errors on. Developing SilverStripe without the error messages is like trying to play chess blindfolded.

In EcommerceRole.php i try to remove these line:

Second, don't change the distributed code unless there's no alternative. You can usually get the behaviour you want by subclassing or extending. e.g.

 * MemberDecorator.php
 * Customise the Member object for use with the ecommerce module
 * Instructions:
 * Add the following line to _config.php
 * DataObject::add_extension('Member', 'MemberDecorator');

class MemberDecorator extends DataObjectDecorator {

	// Customise the order form
	function augmentEcommerceFields($fields) {
		// Remove the country field


Community Member, 102 Posts

26 May 2011 at 5:48am

By the way, this is the line in EcommerceRole::getEcommerceFields() that tells you it can be extended, and how...

$this->owner->extend('augmentEcommerceFields', $fields);

EcommerceRole is adding the extension 'augmentEcommerceFields' to the Member class ($this->owner), so that's what we need to extend with...

DataObject::add_extension('Member', 'MemberDecorator')

Does that make sense?


Community Member, 31 Posts

26 May 2011 at 9:16pm

Yes, it does. But...

I try what you say. I creat file name MemberDecorator.php and put the code from your first reply to it. Than save file in ecommerce/code/model. After it I insert the line

DataObject::add_extension('Member', 'MemberDecorator');
to config file in ecommerce. Run dev/build and try to open www.mysite.tld/checkout. I have blank page.
I can't use dev mode, because it says to me that the Wrong parameter count for session_set_cookie_params()

Maybe I'm doing something wrong. Of course i do.


Community Member, 102 Posts

26 May 2011 at 9:34pm

It will help if you can get dev mode working. What version of php are you running?
Is this the problem:

There may be an alternative way to get error messages via logging.

Add this to _config.php

SS_Log::add_writer(new SS_LogFileWriter('silverstripe-log/silverstripe.log'), SS_Log::NOTICE);

Create a silverstripe-log directory in the SilverStripe root i.e. beside saphire and silverstripe-cache.
Grant write permissions on the silverstripe-log directory to the web process
...I think. if this doesn't work, create a silverstripe-log directory one level higher or inside saphire

if still nothing appears in the log file, add this to Page::init()

SS_Log::log( New Exception('Page::init() - hello'), SS_Log::NOTICE );

I use logging a LOT for debugging as I don't have step-through debugging set up yet..


Community Member, 31 Posts

3 June 2011 at 9:35pm

Hi inCharge,

i try it, but nothing work. Maybe I need to creat silverstripe-log folder up from root directory, but I haven't acces here.
So, is posibility to set default country? I find some advice in the forum, but everything is for old version and it doesn't work.


Community Member, 102 Posts

3 June 2011 at 10:05pm

Edited: 03/06/2011 10:07pm

Try creating the log directory in the saphire directory, and make sure it's writable.

> but I haven't acces here.

You're developing on a shared server? It's much easier to work on a local machine. I recommend setting up your laptop/desktop with a web server, php, mysql etc.

> So, is posibility to set default country?

I would think so, but now sure how, because I avoided the problem by removing country altogether


Community Member, 31 Posts

3 June 2011 at 10:19pm

Yes, i developing on a shared local server. It's because table in database have Upper first letter on Windows, but not on Linux.

Ok... I will try tu unspell the Country. :-)

Go to Top