Page 1 of 1
Need help with PHP Variable name for Order Status
Posted: Mon Apr 29, 2019 11:37 am
by motion2082
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;
}
Re: Need help with PHP Variable name for Order Status
Posted: Mon Apr 29, 2019 6:32 pm
by OSWorX
Yes, your statement is wrong.
Not cheking a text, rather check the id.
Re: Need help with PHP Variable name for Order Status
Posted: Mon Apr 29, 2019 6:48 pm
by D3MO
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;
}
Re: Need help with PHP Variable name for Order Status
Posted: Tue Apr 30, 2019 5:34 am
by straightlight
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;
}
}