Post by motion2082 » Mon Apr 29, 2019 11:37 am

Hey guys,

I would like to check my order status to see if it's "processing"

When I use the following it won't detect the order is processing.
Is my IF statement incorrect?
Using in the model file.

Code: Select all

    if($order_info['status'] == 'processing'){
        $data['show_unpaid'] = false;
        $data['show_paid'] = true;
    } else {
        $data['show_paid'] = false;
        $data['show_unpaid'] = false;
    }

Active Member

Posts

Joined
Tue May 12, 2015 8:48 pm

Post by OSWorX » Mon Apr 29, 2019 6:32 pm

Yes, your statement is wrong.
Not cheking a text, rather check the id.

Full Stack Web Developer :: Dedicated OpenCart Development & Support DACH Region
Contact for Custom Work / Fast Support.


User avatar
Guru Member

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria

Post by D3MO » Mon Apr 29, 2019 6:48 pm

motion2082 wrote:
Mon Apr 29, 2019 11:37 am
Hey guys,

I would like to check my order status to see if it's "processing"

When I use the following it won't detect the order is processing.
Is my IF statement incorrect?
Using in the model file.

Code: Select all

    if($order_info['status'] == 'processing'){
        $data['show_unpaid'] = false;
        $data['show_paid'] = true;
    } else {
        $data['show_paid'] = false;
        $data['show_unpaid'] = false;
    }
it is not correct because statuses comes not as words but as id of the status, the ones you define under admin (system>localisation > order statuses)

By default processing status (if you didnt modified anything) is id = 2

order_status_id and there is no 'status' column it is order_status_id

so based on your requirements:

Code: Select all

    if ($order_info['order_status_id']  == 2) {
        $data['show_unpaid'] = false;
        $data['show_paid'] = true;
    } else {
        $data['show_paid'] = false;
        $data['show_unpaid'] = false;
    }

Opencart Expert | voldemaras@gmail.com
Skype - programanija | Gtalk - voldemaras@gmail.com
Extensions for Opencart @ https://www.opencartextensions.eu / or Opencart Marketplace

Need Custom Module? debug third party module or simply have any question related to Opencart? feel free to contact directly for a live chat session:) - INSTANT LIVE CHAT


User avatar
Active Member

Posts

Joined
Mon Apr 04, 2011 6:57 am

Post by straightlight » Tue Apr 30, 2019 5:34 am

Another way would be by querying all possible statuses despite the IDs but representing all possible processing statuses with the current order ID and the current store (assuming you have the order ID captured with your request).

Code: Select all

$implode = array();

		$order_statuses = $this->config->get('config_processing_status');

		foreach ($order_statuses as $order_status_id) {
			$implode[] = "`order_status_id` = '" . (int)$order_status_id . "'";
		}

		if ($implode) {
		    $query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order` WHERE `order_id` = '" . (int)$order_id . "' AND (" . implode(" OR ", $implode) . ")")->row;
		    
		    if ($query) {		        
				$data['show_unpaid'] = false;
				$data['show_paid'] = true;
			} else {
				$data['show_paid'] = false;
				$data['show_unpaid'] = false;
			}
		}

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: No registered users and 240 guests