Yohanne Posted July 5, 2013 Share Posted July 5, 2013 hello coders. what is the possible reason why i get this warning: Invalid argument supplied for foreach() in and i have no idea behind this code, but i know there is someone else can read this and understand behind the logic. $orders = Order::getOrdersWithInformations(10); $i = 0; foreach($orders AS $order) { $currency = Currency::getCurrency((int)$order['id_currency']); echo ' <tr'.($i % 2 ? ' id="order_line1"' : '').'> <td class="order_td_first order_id">'.(int)$order['id_order'].'</td> <td class="order_customer">'.Tools::htmlentitiesUTF8($order['firstname']).' '.Tools::htmlentitiesUTF8($order['lastname']).'</td> <td class="order_status">'.Tools::htmlentitiesUTF8($order['state_name']).'</td> <td class="order_total">'.Tools::displayPrice((float)$order['total_paid'], $currency).'</td> <td class="order_action"> <a href="index.php?tab=AdminOrders&id_order='.(int)$order['id_order'].'&vieworder&token='.Tools::getAdminTokenLite('AdminOrders').'" title="'.$this->l('Details').'"><img src="../img/admin/details.gif" alt="'.$this->l('See').'" /></a> </td> </tr> '; $i++; } Quote Link to comment Share on other sites More sharing options...
requinix Posted July 5, 2013 Share Posted July 5, 2013 Because $orders is not an array (or other iterable object). Check that getOrdersWithInformation(). Quote Link to comment Share on other sites More sharing options...
applebiz89 Posted July 9, 2013 Share Posted July 9, 2013 If your not sure of the output of the result for getOrdersWithInformation() - wrap a conditional statement around your foreach, checking that the result of getOrdersWithInformation() is an array, so the foreach loop isn't instantiated and causing any errors if the result is false... Quote Link to comment Share on other sites More sharing options...
web_craftsman Posted July 11, 2013 Share Posted July 11, 2013 Show us the output var_dump function will print: $orders = ... var_dump($orders); Quote Link to comment Share on other sites More sharing options...
Maq Posted July 11, 2013 Share Posted July 11, 2013 Post your getOrdersWithInformations() method. Is there a reason it's static? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.