I'm trying to add custom field to the orders. It should only be filled when admin adds order manually from backend form. Output for this field is need only in the orders list.
I have made next changes:
1) added int field order_source to database
2) admin/themes/default/template/controllers/orders/form.tpl
<div class="form-group">
<label class="control-label col-lg-3">Order Source</label>
<div class="col-lg-9">
<select name="order_source" id="order_source">
<option value="1" {if isset($smarty.post.order_source) && $smarty.post.order_source == 1}selected="selected"{/if}>Internal</option>
<option value="2" {if isset($smarty.post.order_source) && $smarty.post.order_source == 2}selected="selected"{/if}>External</option>
<option value="3" {if isset($smarty.post.order_source) && $smarty.post.order_source == 3}selected="selected"{/if}>Distribution</option>
</select>
</div>
</div>
3) override/controllers/admin/AdminOrdersController.php
class AdminOrdersController extends AdminOrdersControllerCore
{
public function __construct()
{
parent::__construct();
$pos = 3;
$this->fields_list = array_slice($this->fields_list, 0, $pos, true) +
array(
'order_source' => array(
'title' => $this->l('Order Source'),
'align' => 'text-center',
'callback' => 'orderSourceCallback',
'type' => 'select',
'list' => array(1 => 'Internal', 2 => 'External', 3 => 'Distribution'),
'filter_key' => 'order_source',
'filter_type' => 'int',
'orderby' => false
)
) + array_slice($this->fields_list, $pos, count($this->fields_list)-$pos, true);
}
}
4) override/classes/order/Order.php
class Order extends OrderCore
{
/** @var integer Order Source */
public $order_source;
public function __construct($id = null, $id_lang = null)
{
self::$definition['fields']['order_source'] = array('type' => self::TYPE_INT);
parent::__construct($id, $id_lang);
}
}
5) I have deleted cache_index.php
Everything works great, It shows in order list. But when I create new order it doesn't save new field. I have tried to find any suggestions and find some but nothing help. When I manually change field value in the database - it shows in the list and I even can filter this column. But still can't save field value.
Please help me