fortuner Posted July 18, 2016 Share Posted July 18, 2016 Hello! I'm stuck with getting Carrier name for order in Backoffice. I've got order id and carrier id and I need to get carreir name. I've wrote a query in Order.php as follows: public static function getCarrierName($id_order) { return Db::getInstance()->executeS(' SELECT cl.`name` as `carrier_name` FROM `'._DB_PREFIX_.'order_carrier` oc LEFT JOIN `'._DB_PREFIX_.'carrier` cl ON (oc.`id_carrier` = cl.`id_carrier`) WHERE oc.`id_order` = '.(int)$id_order); } when I use this in module like this: $orders = Order::getOrdersWithInformations($limit); $body = array(); foreach ($orders as $order) { $id_order = $order['id_order']; $carrier = array(); $carrier = Order::getCarrierName((int)$id_order); $tr = array(); $tr[] = array( 'id' => 'status', 'value' => $carrier, 'class' => 'text-center', ); } it throws [object Object] error. And if I use $carrier['carrier_name'] it throws null I assume my mistake is in calling array value. Please help somebody, i'm desperate Link to comment Share on other sites More sharing options...
vekia Posted July 19, 2016 Share Posted July 19, 2016 dump $carrier variable please, (with var_dump) what you've got there? Link to comment Share on other sites More sharing options...
Inter Svetainė Posted December 21, 2020 Share Posted December 21, 2020 (edited) On 7/19/2016 at 2:33 AM, fortuner said: Hello! I'm stuck with getting Carrier name for order in Backoffice. I've got order id and carrier id and I need to get carreir name. I've wrote a query in Order.php as follows: public static function getCarrierName($id_order) { return Db::getInstance()->executeS(' SELECT cl.`name` as `carrier_name` FROM `'._DB_PREFIX_.'order_carrier` oc LEFT JOIN `'._DB_PREFIX_.'carrier` cl ON (oc.`id_carrier` = cl.`id_carrier`) WHERE oc.`id_order` = '.(int)$id_order); } when I use this in module like this: $orders = Order::getOrdersWithInformations($limit); $body = array(); foreach ($orders as $order) { $id_order = $order['id_order']; $carrier = array(); $carrier = Order::getCarrierName((int)$id_order); $tr = array(); $tr[] = array( 'id' => 'status', 'value' => $carrier, 'class' => 'text-center', ); } it throws [object Object] error. And if I use $carrier['carrier_name'] it throws null I assume my mistake is in calling array value. Please help somebody, i'm desperate not oc.`id_carrier` but a.`id_carrier` regarding to AdminOrdersConstroller constructor. Edited December 21, 2020 by Inter Svetainė (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now