matoola Posted June 3, 2014 Share Posted June 3, 2014 Hi! I am a web designer building a module (sounds great doesn't it ) which exports to text file like this: public function hookActionPaymentConfirmation($params) { // Order ID and delivery date $order_id = sprintf('%07d',$params['id_order']); $send_date = $order->delivery_date; $currency = $this->context->currency->iso_code; $firstname = $this->context->customer->firstname; $lastname = $this->context->customer->lastname; $customer_id = (int)$this->context->customer->id; $delivery = (int)$this->context->cart->id_address_delivery; $postcode = $delivery->postcode; $city = $delivery->city; $iso_code = $this->context->country->iso_code; $total_price = $this->context->cart->getOrderTotal(true); // Setup loop for products $products = $params['cart']->getProducts(true); foreach ($products as $product) { $product_list .= '1|'.$order_id.'|'; $product_list .= 'iterate|'; $product_list .= $product['id_product'].'|'; $product_list .= $product['name'].'|'; $product_list .= $product['quantity'].'|'; $product_list .= $product['ean13'].'|'; $product_list .= "\r\n"; } $order_details = '0|'.$order_id.'|MB|23| DELIVERY DATE:'.$send_date; $customer_details ='|'.$customer_id.'|'.$lastname.' '.$firstname.'| DELIVERY ADDRESS:'.$delivery.'|'.$address1.'|'.$postcode.'|'.$zip_code.'|'.$city.'|'.$iso_code; $other_details = '|'.$total_price.'|'.$currency.'|'; // Setup display of above content $content .= $order_details; $content .= $customer_details; $content .= $other_details; $content .= "\r\n"; $content .= $product_list; $fp = fopen($_SERVER['DOCUMENT_ROOT'] . '/txtexport/I'.$order_id.'.txt','wb'); fwrite($fp,$content); fclose($fp); } It works but I am stuck with getting delivery address (must be separate by address1, address2, city, etc) and delivery time into txt file. Do I need to do db query to get those? Using PS 1.5. Many thanks, Matej Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 3, 2014 Share Posted June 3, 2014 Hi. You need to retrieve the delivery address ID from the order: $order->id_address_delivery You need to create a new Address instance with the retrieved ID and just access its properties (address1, address2 etc) Regards.Robin.The CartExpert Team 1 Link to comment Share on other sites More sharing options...
matoola Posted June 4, 2014 Author Share Posted June 4, 2014 Hi! thank you for the suggestion! I did this below and it works! I got both address and delivery date from $order. $order = new Order(Tools::getValue('id_order')); $delivery = $order->id_address_delivery; $delivery_address = new Address($delivery); $postcode = $delivery_address->postcode; $city = $delivery_address->city; $delivery_date = $order->delivery_date; $send_date = sprintf($delivery_date); Just checking if this is the correct way of doing it? Thanks, Mato Link to comment Share on other sites More sharing options...
CartExpert.net Posted June 4, 2014 Share Posted June 4, 2014 Hi Mato. The absolute correct way would be: $order = new Order($params['id_order']); Regards.Robin.The CartExpert Team 1 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