Chris Posted February 1, 2018 Share Posted February 1, 2018 Hi, I'm working on a very complex Prestashop site that has dozens of customisations and loads of payment modules. I have a simple question that has been causing me so much stress. Every time a NEW order is stored I need to add a field on ps_orders. I have added the field in MySQL. Orders are created after return from all the payment methods but I just want one central php file where I can add my code. I've tried debugging in NetBeans with little success. I've put code in hookactionPaymentConfirmation and hookUpdateOrderStatus but it doesn't always go through here (as far as I can see). I've looked at the class order.php and various controllers. I'm using Prestashop v 1.6 Thanks, Chris Link to comment Share on other sites More sharing options...
Chris Posted February 1, 2018 Author Share Posted February 1, 2018 Thanks for helping. Here is a snippet from the code I am using. I have a module that contains public function install() { return parent::install() && $this->registerHook('actionPaymentConfirmation'); } public function hookactionPaymentConfirmation($params) { die("hapc"); } I placed an order unsing bankwire. The order is placed with a status of awaiting bank wire payment (as expected). It has created an order as expected but not gone through the hook as not paid. If I change the status to paid then it goes through the function as expected. Where do I place the code to write to ps_order when the order record is written to the database (regardless of payment status). Thanks, Chris Link to comment Share on other sites More sharing options...
Chris Posted February 1, 2018 Author Share Posted February 1, 2018 I'm really looking for the 'very bottom' PHP file where it actually does the $order->add() (and I know it's not this actual instruction). Link to comment Share on other sites More sharing options...
DataKick Posted February 1, 2018 Share Posted February 1, 2018 (edited) For update, you can use actionObjectOrderUpdateBefore or actionObjectOrderUpdateAfter If you want to react on order creation, try actionObjectOrderAddBefore or actionObjectOrderAddAfter Edited February 1, 2018 by DataKick (see edit history) Link to comment Share on other sites More sharing options...
Chris Posted February 1, 2018 Author Share Posted February 1, 2018 Thank you. This was very helpful. actionObjectOrderAddBefore is the way to go I'm just stepping through the code to see what I'm missing but with your help I'm getting close. Link to comment Share on other sites More sharing options...
DataKick Posted February 2, 2018 Share Posted February 2, 2018 19 hours ago, Chris said: Thank you. This was very helpful. actionObjectOrderAddBefore is the way to go I'm just stepping through the code to see what I'm missing but with your help I'm getting close. Maybe it would be safer to use actionObjectOrderAddAfter hook, so order will be saved even in case your code accidentally throws some error. Link to comment Share on other sites More sharing options...
Chris Posted February 2, 2018 Author Share Posted February 2, 2018 In the end I created an override of the PaymentModule and put the code in there. It's all working now thanks everyone who helped. Link to comment Share on other sites More sharing options...
hakeryk2 Posted February 27, 2019 Share Posted February 27, 2019 (edited) @Chris so where exactly we can find this crucial moment when order is created through someting like $order->add() or something like this because I also need to find exact moment when ps_orders row is created. I need to find out why some values are badly rounded when it comes to tax excluded prices. Is it in PaymentModule.php in public function validateOrder class? It looks like this. Edit: Yes, this is the crucial function validateOrder is the one. Edited February 27, 2019 by hakeryk2 (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