Added extra field to checkout does not save in database
Posted: Tue Mar 08, 2016 6:30 pm
Hello,
I am using OpenCart 1.5.6.1 and I am trying to add a new field to the payment method section of the checkout, namely "Purchase Order". The field is in the database, and the input box appears in the checkout as it should, but it just does not save to the database like the other fields.
I'm pretty new to this so I'm not sure if I've done it correctly, but in my checkout/confirm.php controller:
I've added $data['purchase_order'] below comments, but this does not seem to take - even if I hard code the result.
In my checkout/payment_method.php controller:
And at the bottom of the same file:
In my model/checkout/order.php file, I've added the field to the addOrder() function, though that also does not work - however if I hard code that, it does so it must be working there.
But, like I say, the field DOES appear on the checkout, the language file is fine as is the template but it's just the processing of the field which does not work.
If anyone can help me with this I would appreciate it as I'm not 100% sure what I'm doing!
Thank you
Michael
I am using OpenCart 1.5.6.1 and I am trying to add a new field to the payment method section of the checkout, namely "Purchase Order". The field is in the database, and the input box appears in the checkout as it should, but it just does not save to the database like the other fields.
I'm pretty new to this so I'm not sure if I've done it correctly, but in my checkout/confirm.php controller:
Code: Select all
$data['products'] = $product_data;
$data['vouchers'] = $voucher_data;
$data['totals'] = $total_data;
$data['comment'] = $this->session->data['comment'];
$data['purchase_order'] = $this->session->data['purchase_order'];
$data['total'] = $total;
In my checkout/payment_method.php controller:
Code: Select all
$this->data['text_purchase_order'] = $this->language->get('text_purchase_order');
....
if (isset($this->session->data['purchase_order'])) {
$this->data['purchase_order'] = $this->session->data['purchase_order'];
} else {
$this->data['purchase_order'] = '';
}
Code: Select all
if (!$json) {
$this->session->data['payment_method'] = $this->session->data['payment_methods'][$this->request->post['payment_method']];
$this->session->data['comment'] = strip_tags($this->request->post['comment']);
$this->session->data['purchase_order'] = trim($this->request->post['purchase_order']);
}
But, like I say, the field DOES appear on the checkout, the language file is fine as is the template but it's just the processing of the field which does not work.
If anyone can help me with this I would appreciate it as I'm not 100% sure what I'm doing!
Thank you
Michael