Jump to content



Latest News: (loading..)

- - - - -

orders.php excluding certain statuses


This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1   pafranklin

pafranklin
  • Members
  • 264 posts

Posted 26 April 2012 - 11:39 PM

Hello,

I am using osC 2.2 MS2 and I wish to develop a new orders.php page where three certain status are excluded.

I have got the following query so far in the orders_raw_query........

$orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, o.fedex_tracking, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s [color=#FF0000][b]where o.orders_status != 1[/b][/color] and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total'  " . (!is_null($search_query)?$search_query:''). " order by o.orders_id DESC";

This excludes any order with a status which equals 1.

My question is to ask how can I amend this query to leave out orders with a status of 1, 2 or 3 for example? I am not particularly proficient in this area so would be grateful if someone could assist or point me in the right direction please?

Very many thanks.
Paul
You will never learn if you don't try. And boy am I trying....!

#2   pafranklin

pafranklin
  • Members
  • 264 posts

Posted 26 April 2012 - 11:46 PM

Sorry for the follow up but I next tried this (and it didn't work)......... Any suggestions gratefully recieved........

	  $orders_query_raw = "select o.orders_id, o.customers_name, o.payment_method, o.date_purchased, o.last_modified, o.currency, o.currency_value, s.orders_status_name, o.fedex_tracking, ot.text as order_total from " . TABLE_ORDERS . " o left join " . TABLE_ORDERS_TOTAL . " ot on (o.orders_id = ot.orders_id), " . TABLE_ORDERS_STATUS . " s [b][color=#FF0000]where (o.orders_status != 1 OR o.orders_status != 2 OR o.orders_status != 11)[/color][/b] and o.orders_status = s.orders_status_id and s.language_id = '" . (int)$languages_id . "' and s.orders_status_id = '" . (int)$status . "' and ot.class = 'ot_total'  " . (!is_null($search_query)?$search_query:''). " order by o.orders_id DESC";

You will never learn if you don't try. And boy am I trying....!

#3   NodsDorf

NodsDorf
  • Members
  • 1,274 posts

Posted 27 April 2012 - 01:31 AM

The syntax you're looking for is the SQL IN statement.

More specifically NOT IN

WHERE o.orders_status NOT IN ('1','2','3')

Hope that helps.

#4   pafranklin

pafranklin
  • Members
  • 264 posts

Posted 27 April 2012 - 08:48 PM

Dear NodsDorf,

Very many thanks - this works perfect and my orders.php can now exclue the statuses I need.

Thank you for the replay and assistance!

Paul
You will never learn if you don't try. And boy am I trying....!