dhurley Posted January 16, 2014 Share Posted January 16, 2014 I have a module that runs on the orders page in the back office. I don't know how to get the shipping address of the order. Is there an easy method for getting this? Thanks! Link to comment Share on other sites More sharing options...
netplayer Posted January 16, 2014 Share Posted January 16, 2014 Don't know of a built-in method but you could include a simple function like following in your module's class. Better practice would be to use sql join in one single query to return just the single value you wish but i thought maybe it's more widely useful demonstrating all the data that can be retrieved within an array. //a function that returns all order data in the $orderdata array. Debug the array to see how you canretrieve the field you are interested in. For example to retrieve delivery address1 use getOrderData($orderid)['address1']; ($orderid is the id of your order) private function getOrderData($orderid){ $sql='SELECT * FROM '._DB_PREFIX_.'orders o WHERE `id_order`='.(int)$orderid;//$orderid is the id of your order $result = Db::getInstance()->ExecuteS($sql); if($result){ foreach ($result as $row){ foreach ($row as $key=>$value){ $data[$key]=$value; } } } $query='SELECT * FROM `'._DB_PREFIX_.'address` WHERE `id_address`='.(int)$data["id_address_delivery"]; $result = Db::getInstance()->ExecuteS($query); if($result){ foreach($result as $row){ foreach ($row as $key=>$value){ $orderData[$key]=$value; } } } return $orderData; } Link to comment Share on other sites More sharing options...
dhurley Posted January 16, 2014 Author Share Posted January 16, 2014 That worked well thank you!! Link to comment Share on other sites More sharing options...
rmatcar Posted January 21, 2014 Share Posted January 21, 2014 Hi dhurley, I want to create a simple module to add some information on the order page in the back office. I don't know how to start and I would save a lot of time with your module Could you gave me the structure of your module please? I can edit your shipping address and put the information I need. Thank you in advance. Regards. Link to comment Share on other sites More sharing options...
dhurley Posted January 21, 2014 Author Share Posted January 21, 2014 I would recommend copying an existing module. Something simple like the blockrss module. Then you have a structure to work with. Combine that with the Presta documentation and you should be good to go. 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