Post by OnNets » Fri Feb 12, 2016 11:59 pm

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

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by IP_CAM » Sat Feb 13, 2016 8:45 am

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/

My Github OC Site: https://github.com/IP-CAM
5'200 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.


User avatar
Legendary Member

Posts

Joined
Tue Mar 04, 2014 1:37 am
Location - Switzerland

Post by gogoweb » Sat Feb 13, 2016 10:33 am

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

Code: Select all

<?php echo $ref_no; ?>
If you are not sure if you did it right, do some

Code: Select all

 var_dump(  $data['ref_no']) 
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 :)

All mods | OpenCart Bulk Related Products Ultimate Edition |GeoIP hide Prices / no add to cart by country| CSS override | Direct link to checkout / skip add to cart / buy now link | AUTO pilot - reward & purchase points


New member

Posts

Joined
Sat Oct 18, 2014 6:45 pm


Post by OnNets » Sat Feb 13, 2016 12:24 pm

Hi gogoweb,

I have follow your instruction. But the ref_no value did not store in the database. Can you help further?

Thanks,
onnets

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by OnNets » Sat Feb 13, 2016 12:26 pm

IP_CAM wrote: Address Landmark (OCMOD)
http://www.opencart.com/index.php?route ... n_id=20806
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

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by OnNets » Fri Mar 04, 2016 6:05 pm

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

New member

Posts

Joined
Wed Jan 06, 2010 5:53 pm

Post by HAO » Fri Apr 29, 2016 3:29 pm

IP_CAM wrote:Possibly, one of those could match:

Custom field invoice and email
http://www.opencart.com/index.php?route ... n_id=23447

Good Luck ;)
Ernie
hitline.info/shop/
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?

HAO
Active Member

Posts

Joined
Fri Jun 03, 2011 2:52 pm
Who is online

Users browsing this forum: No registered users and 84 guests