Post by egemenk » Thu May 24, 2012 9:02 pm

Hi,

I'm writing a simple payment module on v1.5.2.1, which basically charges a credit card. I want to change the order status if payment is failed (e.g. denied credit card).
I see that on catalog/model/checkout/order.php, the two methods, confirm and update, are used for this task. Since the order is not confirmed yet, I only want a status change (e.g. failed). However, without calling the confirm method first, it's not possible to change the status of the order, because of the code on line #573 I guess:

Code: Select all

if ($order_info && $order_info['order_status_id']) {
Am I following the wrong path on this?

Newbie

Posts

Joined
Thu May 24, 2012 8:01 pm

Post by Avvici » Fri May 25, 2012 6:09 am

The confirm function does not mean "status confirmed." It's a function to be called once the order is verified and payment gateway does not return an error or failed payment. It all depends on the arguments sent to the function.
I don' t know how you are setting up your module but I would just call the update function on the FALSE return of your order like this:

Code: Select all

if(success){
do this
}else{
$order_status_id = 2;
$this->model_checkout_order->update($this->session->data['order_id'], $order_status_id, $message, false);}
You will need to look up your status ID in your database

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by egemenk » Fri May 25, 2012 6:21 am

Hi avvici, thanks for your answer. I did exactly as you said, but the problem is; since the order_status_id is equal to 0, it just bypasses the update function and the order doesn't get updated. As I have mentioned in my first post, there is this order_status_id check at the beginning of the update function which makes it impossible to update the order without calling the confirm function first. Or am I missing something?

Newbie

Posts

Joined
Thu May 24, 2012 8:01 pm

Post by Avvici » Fri May 25, 2012 10:24 am

The default order status ID of "failed" is 10. Just push that through. An order initially is set at status of 0. This is by default and will stay that way unless updated further in the ordering process .
$order_status_id = 10;
$this->model_checkout_order->update($this->session->data['order_id'], $order_status_id, $message, false);}

User avatar
Expert Member

Posts

Joined
Tue Apr 05, 2011 12:09 pm
Location - Asheville, NC

Post by AbeMark » Sat Mar 18, 2017 3:38 pm

OC 2.3.0.2

hi guys, currently the code update order status id to 1 when user click continue at payment method page 5th step. i want to update order status id from 0 to 1 once user click confirm button on 6th step not on 5th step.
so it something like:

if (confirm_button){
update order status id to 1
generate payment link ....
}

do i need to update here?
catalog/controller/extension/payment/custom.php

mind to give example code?

Code: Select all

public function index()
	{
		$this->load->language('extension/payment/custom');
		$data['button_confirm'] = $this->language->get('button_confirm');
		
		$this->load->model('checkout/order');
		$order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
		
		if (confirm_button){
		update order status id to 1
		generate payment link ....
		}
		

Newbie

Posts

Joined
Wed Mar 15, 2017 11:57 am
Who is online

Users browsing this forum: No registered users and 112 guests