Page 1 of 1
[Help] Add Custom Fields To Admin Order Form (OC2.1)
Posted: Fri Feb 12, 2016 11:59 pm
by OnNets
Hi,
Can anyone show me how to add custom field in admin order form?
I need a ref_no so that I can put a value when adding new order.
I have already create ref_no in database order table.
I just not sure how to modify in the files because OC2 now use API to create order.
Please teach me where to modify the files in admin and catalog.
Thanks,
onnets
Re: [Help] Add Custom Fields To Admin Order Form (OC2.1)
Posted: Sat Feb 13, 2016 8:45 am
by IP_CAM
Possibly, one of those could match:
Custom field invoice and email
http://www.opencart.com/index.php?route ... n_id=23447
Address Landmark (OCMOD)
http://www.opencart.com/index.php?route ... n_id=20806
Good Luck
Ernie
hitline.info/shop/
Re: [Help] Add Custom Fields To Admin Order Form (OC2.1)
Posted: Sat Feb 13, 2016 10:33 am
by gogoweb
I assume you are not willing to use the default custom_field functionality.
Basically, you need to read and write this field. The API will need just few lines to read it from the request and pass it to DB.
In
catalog/controller/api/order.php
add this in
public function add() {
Code: Select all
if (isset($this->request->post['ref_no'])) {
$order_data['ref_no'] = $this->request->post['ref_no'];
} else {
$order_data['ref_no'] = '';
}
In
catalog/model/checkout/order.php
in
public function addOrder($data) { edit the SQL query starting with this
INSERT INTO `" . DB_PREFIX . "order to add this:
Code: Select all
, ref_no = '" . $this->db->escape($data['ref_no']) . "'
You will need to enter it in the editOrder function too.
To read it:
In
catalog/model/checkout/order.php
in
public function getOrder( edit the
return array( and add this:
2nd place
In
admin/model/sale/order.php
in
public function getOrder( edit the
return array( and add this:
Code: Select all
'ref_no' => $order_query->row['ref_no'],
In
admin/controller/sale/order.php
in
public function info() { after
$this->load->language('sale/order'); add this
Code: Select all
$data['ref_no'] = $order_info['ref_no'];
To display it:
In
admin/view/sale/order.tpl add this where you like
If you are not sure if you did it right, do some
in the controllers / models;
My strong recommendation is to do this in a vQmod XML and never directly to your php files to avoid trouble.
Good luck

Re: [Help] Add Custom Fields To Admin Order Form (OC2.1)
Posted: Sat Feb 13, 2016 12:24 pm
by OnNets
Hi gogoweb,
I have follow your instruction. But the ref_no value did not store in the database. Can you help further?
Thanks,
onnets
Re: [Help] Add Custom Fields To Admin Order Form (OC2.1)
Posted: Sat Feb 13, 2016 12:26 pm
by OnNets
This is what gogoweb is pointing in the code but the problem is that the value did not save in the database.
Any help you can give?
Thanks,
Stenno
Re: [Help] Add Custom Fields To Admin Order Form (OC2.1)
Posted: Fri Mar 04, 2016 6:05 pm
by OnNets
OnNets wrote:Can anyone show me how to add ref_no in ADMIN ORDER FORM?
I need a ref_no so that I can put a value when adding new order.
I have already create ref_no in database order table.
I just not sure how to modify in the files because OC2 now use API to create order.
Please teach me where to modify the files in admin and catalog.
Anyone can help? Please?
Thanks.
onnets
Re: [Help] Add Custom Fields To Admin Order Form (OC2.1)
Posted: Fri Apr 29, 2016 3:29 pm
by HAO
I have use this extension.
But I create custom fields, not all customers must be filled.
In the current code, With or without fill in this field will display {custom_field_1} the data.
This is an obsession.
We hope that if do not fill is hidden fields, May I ask anybody know how to fix it?