Post by mediaorb » 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:

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;
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:

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'] = '';
}
And at the bottom of the same file:

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']);
}	
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

Newbie

Posts

Joined
Tue Mar 08, 2016 6:15 pm

Post by villagedefrance » Tue Mar 08, 2016 10:43 pm

I think you have to add some "purchase order" code in the "session" Class, in your System > Library > Session.php file, because you are calling $this->session->data['purchase_order'].

OpenCart custom solutions @ https://villagedefrance.net


User avatar
Active Member

Posts

Joined
Wed Oct 13, 2010 10:35 pm
Location - UK

Post by artcore » Tue Mar 08, 2016 11:02 pm

I think the payment method is sending the data via ajax so you need to add the variable in the data object of the ajax function.

Attn: I no longer provide OpenCart extensions, nor future support - this includes forum posts.
Reason: OpenCart version 3+ ;D

Thanks!


User avatar
Active Member

Posts

Joined
Tue Jul 09, 2013 4:13 am
Location - The Netherlands
Who is online

Users browsing this forum: No registered users and 72 guests