Version: current

# Class Order

Заказ

  Object
  ViewableData implements IteratorAggregate
  DataObject implements DataObjectInterface, i18nEntityProvider
  Order

Package: cart
Author: inxo, dvp
Located at cart/code/Order.php

## Methods summary

`public static` | # `set_required_fields( array $val )` Изменение списка обязательных полей заказа Изменение списка обязательных полей заказа #### Parameters $val array $val - новый список обязательных полей
`public static string` | # `status_title( string $status )` Локализованное название статуса Локализованное название статуса Локализация с помощью файла переводов, константы вида "Order.Status_{$status}" #### Parameters $status string $status - код статуса #### Returns `string` string
`public static` | # `get_by_hash( mixed $hash )`
`public array|string` | # `fieldLabels( boolean $includerelations = true )` Get any user defined searchable fields labels that exist. Allows overriding of default field names in the form interface actually presented to the user. Get any user defined searchable fields labels that exist. Allows overriding of default field names in the form interface actually presented to the user. The reason for keeping this separate from searchable_fields, which would be a logical place for this functionality, is to avoid bloating and complicating the configuration array. Currently much of this system is based on sensible defaults, and this property would generally only be set in the case of more complex relationships between data object being required in the search interface. Generates labels based on name of the field itself, if no static property `DataObject::$field_labels` exists. #### Parameters $includerelations boolean $includerelations a boolean value to indicate if the labels returned include relation fields #### Returns `array|string` Array of all element labels if no argument given, otherwise the label of the field #### Uses `mixed` ``FormField::name_to_label()`` #### Overrides `DataObject::fieldLabels`
`public array` | # `getRequredFields( )` Список обязательных полей для формы заказа Список обязательных полей для формы заказа В расширении можно определить метод: updateRequiredFields(array &$fields) - для изменения списка обязательных полей формы #### Returns `array` array
`public `FieldSet`` | # `getContactFields( )` Список полей для шага контактной информации Список полей для шага контактной информации В расширении можно определить метод: updateContactFields(FieldSet &$fields) - для изменения списка полей #### Returns ``FieldSet`` FieldSet
`public `FieldSet`` | # `getSummaryFields( )` Список полей для шага подтверждения Список полей для шага подтверждения В расширении можно определить метод: updateSummaryFields(FieldSet &$fields) - для изменения списка полей формы #### Returns ``FieldSet`` FieldSet
`public `FieldSet`` | # `getFrontendFields( )` Список полей для формы заказа в целом Список полей для формы заказа в целом В расширении можно определить метод: updateFrontendFields(FieldSet &$fields) - для изменения списка полей формы #### Returns ``FieldSet`` FieldSet
`public `FieldSet`` | # `getCMSFields( )` Centerpiece of every data administration interface in Silverstripe, which returns a `FieldSet` suitable for a `Form` object. If not overloaded, we're using `DataObject::scaffoldFormFields()` to automatically generate this set. To customize, overload this method in a subclass or decorate onto it by using DataObjectDecorator->updateCMSFields(). Centerpiece of every data administration interface in Silverstripe, which returns a `FieldSet` suitable for a `Form` object. If not overloaded, we're using `DataObject::scaffoldFormFields()` to automatically generate this set. To customize, overload this method in a subclass or decorate onto it by using DataObjectDecorator->updateCMSFields().
    klass MyCustomClass extends DataObject {
            static $db = array('CustomProperty'=>'Boolean');

            public function getCMSFields() {
                    $fields = parent::getCMSFields();
                    $fields->addFieldToTab('Root.Content',new CheckboxField('CustomProperty'));
            return $fields;
    }
    }
#### Returns ``FieldSet`` Returns a TabSet for usage within the CMS - don't use for frontend forms. #### See Good example of complex FormField building: SiteTree::getCMSFields() #### Overrides `DataObject::getCMSFields`
`public` | # `onBeforeWrite( )` Event handler called before writing to the database. You can overload this to clean up or otherwise process data before writing it to the database. Don't forget to call parent::onBeforeWrite(), though! Event handler called before writing to the database. You can overload this to clean up or otherwise process data before writing it to the database. Don't forget to call parent::onBeforeWrite(), though! This called after $this->validate(), so you can be sure that your data is valid. #### Uses ``DataObjectDecorator::onBeforeWrite()`` #### Overrides `DataObject::onBeforeWrite`
`public` | # `onAfterWrite( )` Event handler called after writing to the database. You can overload this to act upon changes made to the data after it is written. $this->changed will have a record database. Don't forget to call parent::onAfterWrite(), though! Event handler called after writing to the database. You can overload this to act upon changes made to the data after it is written. $this->changed will have a record database. Don't forget to call parent::onAfterWrite(), though! #### Uses ``DataObjectDecorator::onAfterWrite()`` #### Overrides `DataObject::onAfterWrite`
`public` | # `OnBeforeDelete( )`
`public integer` | # `MinTotalPrice( boolean $real = false )` Возвращает минимальную сумму для заказа Возвращает минимальную сумму для заказа #### Parameters $real bool $real - возвращать число, а не объект CatalogPrice #### Returns `integer` int
`public boolean` | # `CanCheckout( integer $price = null )` Проверяет достаточна ли сумма заказа для оформления покупки Проверяет достаточна ли сумма заказа для оформления покупки #### Parameters $price int $price - сумма заказа [сумма в корзине] #### Returns `boolean` boolean
`public` | # `calculateGrandTotal( )`
`public` | # `getGrandTotal( )`
`public boolean` | # `exists( )` Returns true if this object "exists", i.e., has a sensible value. The default behaviour for a DataObject is to return true if the object exists in the database, you can override this in subclasses. Returns true if this object "exists", i.e., has a sensible value. The default behaviour for a DataObject is to return true if the object exists in the database, you can override this in subclasses. #### Returns `boolean` true if this object exists #### Overrides `DataObject::exists`
`public `ValidationResult`` | # `validate( )` Валидация заказа Валидация заказа Выполняется каждый раз при write() поэтому надо быть остороджным #### Returns ``ValidationResult`` ValidationResult #### Overrides `DataObject::validate`
`public string` | # `Currency( )` Возвращает валюту заказа Возвращает валюту заказа В настоящее время в заказе не хранится, а используется настройка валяюты каталога #### Returns `string` string
`public` | # `getTotalPrice( )`
`public` | # `getTotalQuantity( )`
`public` | # `StatusTitle( )`
`public` | # `ItemName( )`
`public` | # `updateForAjax( array & $js )` Возвращает данные для ajax корзины. Возвращает данные для ajax корзины. #### Parameters $js array $js
`public` | # `canCancel( )`
`public` | # `Items( )`
`public `DataObjectSet`` | # `createItems( array $items, boolean $write = false )` Создаем список покупок Создаем список покупок #### Parameters $items array $items - список товаров $write bool $write - сохранять ли его в БД #### Returns ``DataObjectSet`` - список товаров в заказе
`protected `DataObjectSet`` | # `itemsFromDatabase( )` Список товаров из БД Список товаров из БД #### Returns ``DataObjectSet`` - список товаров в заказе
`protected `DataObjectSet`` | # `createDataObjectSet( array $items )` Создает DataObjectSet из массива товаров из корзины Создает DataObjectSet из массива товаров из корзины #### Parameters $items array $items #### Returns ``DataObjectSet`` - список товаров в заказе
`public` | # `Link( )`
`public` | # `PrintLink( )`
`public` | # `CancelLink( )`

### Methods inherited from DataObject

`Aggregate()`, `RelationshipAggregate()`, `__construct()`, `baseTable()`, `belongs_to()`, `buildDataObjectSet()`, `buildSQL()`, `can()`, `canCreate()`, `canDelete()`, `canEdit()`, `canView()`, `castedUpdate()`, `composite_fields()`, `context_obj()`, `customDatabaseFields()`, `custom_database_fields()`, `data()`, `databaseFields()`, `databaseIndexes()`, `database_extensions()`, `database_fields()`, `db()`, `dbObject()`, `debug()`, `defaultSearchFilters()`, `defineMethods()`, `delete()`, `delete_by_id()`, `destroy()`, `disableCMSFieldsExtensions()`, `disable_subclass_access()`, `duplicate()`, `enableCMSFieldsExtensions()`, `enable_subclass_access()`, `extendedSQL()`, `fieldLabel()`, `flushCache()`, `flush_and_destroy_cache()`, `forceChange()`, `get()`, `getAllFields()`, `getCMSActions()`, `getChangedFields()`, `getClassAncestry()`, `getComponent()`, `getComponents()`, `getComponentsQuery()`, `getDefaultSearchContext()`, `getField()`, `getFrontEndFields()`, `getManyManyComponents()`, `getManyManyComponentsQuery()`, `getManyManyFilter()`, `getManyManyJoin()`, `getRemoteJoinField()`, `getReverseAssociation()`, `getTitle()`, `get_by_id()`, `get_one()`, `get_validation_enabled()`, `hasDatabaseField()`, `hasField()`, `hasOwnTableDatabaseField()`, `hasValue()`, `has_many()`, `has_one()`, `has_own_table()`, `i18n_plural_name()`, `i18n_singular_name()`, `inheritedDatabaseFields()`, `instance_get()`, `instance_get_one()`, `isChanged()`, `isEmpty()`, `isInDB()`, `is_composite_field()`, `many_many()`, `many_many_extraFields()`, `merge()`, `newClassInstance()`, `onAfterDelete()`, `onBeforeDelete()`, `plural_name()`, `populateDefaults()`, `provideI18nEntities()`, `relObject()`, `requireDefaultRecords()`, `requireTable()`, `reset()`, `scaffoldFormFields()`, `scaffoldSearchFields()`, `searchableFields()`, `setCastedField()`, `setClassName()`, `setComponent()`, `setField()`, `set_context_obj()`, `set_validation_enabled()`, `singular_name()`, `summaryFields()`, `toMap()`, `update()`, `write()`, `writeComponents()`, `writeWithoutVersion()`

### Methods inherited from ViewableData

`ATT_val()`, `BaseHref()`, `CSSClasses()`, `ColumnBreak()`, `ColumnCalc()`, `ColumnNumber()`, `ColumnPad()`, `ColumnPos()`, `CurrentMember()`, `CurrentPage()`, `Debug()`, `Even()`, `EvenOdd()`, `First()`, `FirstLast()`, `HasPerm()`, `IsAjax()`, `JS_val()`, `Last()`, `Me()`, `Middle()`, `MiddleString()`, `Modulus()`, `MultipleOf()`, `Odd()`, `Pos()`, `RAW_val()`, `SQL_val()`, `ThemeDir()`, `ThemeName()`, `Top()`, `TotalItems()`, `XML_val()`, `__get()`, `__isset()`, `__set()`, `buildCastingCache()`, `cachedCall()`, `castingClass()`, `castingHelper()`, `castingHelperPair()`, `castingObjectCreator()`, `castingObjectCreatorPair()`, `customise()`, `escapeTypeForField()`, `getIterator()`, `getSecurityID()`, `getXMLValues()`, `i18nLocale()`, `iteratorProperties()`, `obj()`, `renderWith()`, `setCustomisedObj()`

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

`public static array` | $db | # Database field definitions. This is a map from field names to field type. The field type should be a class that extends . Database field definitions. This is a map from field names to field type. The field type should be a class that extends .
`public static array` | $has_one | # One-to-zero relationship defintion. This is a map of component name to data type. In order to turn this into a true one-to-one relationship you can add a `DataObject::$belongs_to` relationship on the child class. One-to-zero relationship defintion. This is a map of component name to data type. In order to turn this into a true one-to-one relationship you can add a `DataObject::$belongs_to` relationship on the child class. Note that you cannot have a has_one and belongs_to relationship with the same name.
`public static array` | $has_many | # This defines a one-to-many relationship. It is a map of component name to the remote data class. This defines a one-to-many relationship. It is a map of component name to the remote data class. This relationship type does not actually create a data structure itself - you need to define a matching $has_one relationship on the child class. Also, if the $has_one relationship on the child class has multiple links to this class you can use the syntax "ClassName.HasOneRelationshipName" in the remote data class definition to show which foreign key to use.
`public static array` | $defaults | # Inserts standard column-values when a DataObject is instanciated. Does not insert default records `DataObject::$default_records`. This is a map from fieldname to default value. Inserts standard column-values when a DataObject is instanciated. Does not insert default records `DataObject::$default_records`. This is a map from fieldname to default value. If you would like to change a default value in a sub-class, just specify it. - If you would like to disable the default value given by a parent class, set the default value to 0,'',or false in your subclass. Setting it to null won't work.
`public static array` | $casting | # Use a casting object for a field. This is a map from field name to class name of the casting object. Use a casting object for a field. This is a map from field name to class name of the casting object.
`public static array` | $searchable_fields | # Default list of fields that can be scaffolded by the ModelAdmin search interface. Default list of fields that can be scaffolded by the ModelAdmin search interface. Overriding the default filter, with a custom defined filter:
           static $searchable_fields = array(
              "Name" => "PartialMatchFilter"
    );
Overriding the default form fields, with a custom defined field. The 'filter' parameter will be generated from `DBField::$default_search_filter_class`. The 'title' parameter will be generated from DataObject->fieldLabels().
           static $searchable_fields = array(
              "Name" => array(
                           "field" => "TextField"
                   )
    );
Overriding the default form field, filter and title:
           static $searchable_fields = array(
              "Organisation.ZipCode" => array(
                           "field" => "TextField",
                           "filter" => "PartialMatchFilter",
                           "title" => 'Organisation ZIP'
                   )
    );
`public static string` | $default_sort | # The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided. The default sort expression. This will be inserted in the ORDER BY clause of a SQL query if no other sort expression is provided.
`public static array` | $summary_fields | # Provides a default list of fields to be used by a 'summary' view of this object. Provides a default list of fields to be used by a 'summary' view of this object.
`public static array` | $required_fields | #
`public static boolean` | $use_shipping | #
`public static boolean` | $use_payments | #
`public static boolean` | $can_cancel_before_payment | #
`public static boolean` | $can_cancel_before_processing | #
`public static boolean` | $can_cancel_before_sending | #
`public static boolean` | $can_cancel_after_sending | #

### Properties inherited from DataObject

`$allowed_actions`, `$ancestry`, `$api_access`, `$belongs_many_many`, `$belongs_to`, `$brokenOnDelete`, `$brokenOnWrite`, `$cache_get_one`, `$cache_has_own_table`, `$cache_has_own_table_field`, `$componentCache`, `$components`, `$create_table_options`, `$default_records`, `$destroyed`, `$field_labels`, `$indexes`, `$many_many`, `$many_many_extraFields`, `$original`, `$plural_name`, `$record`, `$singular_name`

### Properties inherited from ViewableData

`$customisedObject`, `$default_cast`, `$failover`, `$iteratorPos`, `$iteratorTotalItems`

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -