Andrew Watson Posted October 28, 2014 Share Posted October 28, 2014 I have a module which creates a text file for new customer and new orders. This text file is used to sync with our accounting program. But what I want its that whenever it creates the text file for new orders, it ALSO creates a txt file for the customer. The php is here: public function hookCreateAccount($params) { include_once('classes/Factusol.php' ); return Factusol::createCustomerFile($params['newCustomer']); } public function hookOrderConfirmation($params) { include_once('classes/Factusol.php' ); $order = $params['objOrder']; if($order->valid == '1') return Factusol::createOrderFile($order); return false; } So basically I want what happens in hookCreateAccount to also happen in hookOrderConfirmation. The twist is that the customer is not new. I figure I just need to add the following line to hookOrderConfirmation, but I don't know what syntax would be correct for an existing customer. return Factusol::createCustomerFile($params['newCustomer']); Does anyone have any thoughts? Or do you need additional info? Link to comment Share on other sites More sharing options...
bellini13 Posted October 28, 2014 Share Posted October 28, 2014 I am assuming Factusol::createCustomerFile is expecting the customer object, and we can create that from the Order object. So you should be able to do this in your hookOrderConfirmation function $id_customer = $order->id_customer; $customer = new Customer($id_customer); Factusol::createCustomerFile($customer); 1 Link to comment Share on other sites More sharing options...
Andrew Watson Posted October 28, 2014 Author Share Posted October 28, 2014 (edited) OK. That looks exactly like what I thought (i.e. use the order to get customer then create customer file for that customer) ... but before I test it, isn't the "return" missing? Shouldn't it be: $id_customer = $order->id_customer; $customer = new Customer($id_customer); Return Factusol::createCustomerFile($customer); and lastly, is there supposed to be a space between "new" and "customer"? In the code above that text doesn't have a space and I'm not sure why that would be different. Edited October 28, 2014 by Andrew Watson (see edit history) Link to comment Share on other sites More sharing options...
Andrew Watson Posted October 28, 2014 Author Share Posted October 28, 2014 Ok. I pasted in that code with the "return" added and it works like a charm. I've done some test and it seams to work so I put it into production, lets see what happens when real orders are thrown at it. Thanks very much. I just didn't have the knowledge to get the customer data so that it was sent through correctly. Much appreciated! Link to comment Share on other sites More sharing options...
Recommended Posts