Custom fields for orders, customers

You may want to store additional information for each customer. In a nutshell you need to update your DataModel, and any places where the data is entered. This can generally be done by creating extensions.

First read the SilverStripe documentation about decorators.


Customer fields are saved to both Members and Orders.

Add database field(s) to the model

In [mysite]/code/ExtendedCustomer.php

class ExtendedCustomer extends DataObjectDecorator{

    function extraStatics(){
        return array(
            'db' => array(
                'MyExtraField' => 'Varchar'

To your _config.php file, add:


Update form(s)

To let your website visitors actually enter the data, you will need to modify various forms.

In [mysite]/code/ExtendedOrderForm.php

class ExtendedOrderForm extends Extension{

    function updateFields($fields){
        $fields->push(new TextField("MyExtraField","My Extra Field"));


To your _config.php file, add:


Note: remember to flush the class manifest by adding ?flush=1 to your site url.

comments powered by Disqus