title: Opencart Order List by status
body: <p>I'm currently using opencart, in the admin panel there is an orders section.</p>
  
  <p>Within the code there is a loop that displays each order.
  here is the loop</p>
  
  <pre><code>&lt;?php foreach ($orders as $order) { ?&gt;
              &lt;tr&gt;
                &lt;td style="text-align: center;"&gt;&lt;?php if ($order['selected']) { ?&gt;
                  &lt;input type="checkbox" name="selected[]" value="&lt;?php echo $order['order_id']; ?&gt;" checked="checked" /&gt;
                  &lt;?php } else { ?&gt;
                  &lt;input type="checkbox" name="selected[]" value="&lt;?php echo $order['order_id']; ?&gt;" /&gt;
                  &lt;?php } ?&gt;&lt;/td&gt;
                &lt;td class="right"&gt;&lt;?php echo $order['order_id']; ?&gt;&lt;/td&gt;
                &lt;td class="left"&gt;&lt;?php echo $order['customer']; ?&gt;&lt;/td&gt;
                &lt;td class="left"&gt;&lt;?php echo $order['status']; ?&gt;&lt;/td&gt;
                &lt;td class="right"&gt;&lt;?php echo $order['total']; ?&gt;&lt;/td&gt;
                &lt;td class="left"&gt;&lt;?php echo $order['date_added']; ?&gt;&lt;/td&gt;
                &lt;td class="left"&gt;&lt;?php echo $order['date_modified']; ?&gt;&lt;/td&gt;
                &lt;td class="right"&gt;&lt;?php foreach ($order['action'] as $action) { ?&gt;
                  [ &lt;a href="&lt;?php echo $action['href']; ?&gt;"&gt;&lt;?php echo $action['text']; ?&gt;&lt;/a&gt; ]
                  &lt;?php } ?&gt;&lt;/td&gt;
              &lt;/tr&gt;
  &lt;?php } ?&gt;
  </code></pre>
  
  <p>There is also a filter above this to sort orders.</p>
  
  <pre><code>&lt;tr class="filter"&gt;
                &lt;td&gt;&lt;/td&gt;
                &lt;td align="right"&gt;&lt;input type="text" name="filter_order_id" value="&lt;?php echo $filter_order_id; ?&gt;" size="4" style="text-align: right;" /&gt;&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="filter_customer" value="&lt;?php echo $filter_customer; ?&gt;" /&gt;&lt;/td&gt;
                &lt;td&gt;&lt;select name="filter_order_status_id"&gt;
                    &lt;option value="*"&gt;&lt;/option&gt;
                    &lt;?php if ($filter_order_status_id == '0') { ?&gt;
                    &lt;option value="0" selected="selected"&gt;&lt;?php echo $text_missing; ?&gt;&lt;/option&gt;
                    &lt;?php } else { ?&gt;
                    &lt;option value="0"&gt;&lt;?php echo $text_missing; ?&gt;&lt;/option&gt;
                    &lt;?php } ?&gt;
                    &lt;?php foreach ($order_statuses as $order_status) { ?&gt;
                    &lt;?php if ($order_status['order_status_id'] == $filter_order_status_id) { ?&gt;
                    &lt;option value="&lt;?php echo $order_status['order_status_id']; ?&gt;" selected="selected"&gt;&lt;?php echo $order_status['name']; ?&gt;&lt;/option&gt;
                    &lt;?php } else { ?&gt;
                    &lt;option value="&lt;?php echo $order_status['order_status_id']; ?&gt;"&gt;&lt;?php echo $order_status['name']; ?&gt;&lt;/option&gt;
                    &lt;?php } ?&gt;
                    &lt;?php } ?&gt;
                  &lt;/select&gt;&lt;/td&gt;
                &lt;td align="right"&gt;&lt;input type="text" name="filter_total" value="&lt;?php echo $filter_total; ?&gt;" size="4" style="text-align: right;" /&gt;&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="filter_date_added" value="&lt;?php echo $filter_date_added; ?&gt;" size="12" class="date" /&gt;&lt;/td&gt;
                &lt;td&gt;&lt;input type="text" name="filter_date_modified" value="&lt;?php echo $filter_date_modified; ?&gt;" size="12" class="date" /&gt;&lt;/td&gt;
                &lt;td align="right"&gt;&lt;a onclick="filter();" class="button"&gt;&lt;?php echo $button_filter; ?&gt;&lt;/a&gt;&lt;/td&gt;
              &lt;/tr&gt;
  </code></pre>
  
  <p>What i'm trying to do is underneath the orders, display all the orders in another table with a set status.</p>
  
  <p>for example, when an order is complete (status id = 5) i want it to move from one table to another</p>
  
  <p><img src="https://i.stack.imgur.com/Cc1j6.png" alt="enter image description here"></p>
  
  <p>you can see the "complete order" which has a status_id of "5" and the pending orders which have an order_status of "1".</p>
  
  <p>I'm not worried about how the table looks, i can do that within a loop, but i don't know how to get the information into a loop to display orders with a set status, I've already tried</p>
  
  <pre><code>&lt;?php foreach ($orders as $order) { ?&gt;
    &lt;?php if ($order_status['order_status_id'] = 5 ?&gt;
      some data here
    &lt;?php ?&gt;
  &lt;?php ?&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;?php foreach ($orders as $order) { ?&gt;
    &lt;?php if ($order['status'] = 5 ?&gt;
      some data here
    &lt;?php ?&gt;
  &lt;?php ?&gt;
  </code></pre>
  
  <p>Am i getting things around the wrong way?</p>
  
  <p>The loops isn't working, I've also tried putting the if statement before the foreach for both of the above, but its not working.</p>
  
  <p>Can anyone help?</p>