marco.predari Posted November 18, 2015 Share Posted November 18, 2015 Hi everyone, I am new in the prestashop community and I have a question about developing modules in PS. I am creating a module that has to make some stuff when a new order is submitted. Well i found the "actionValidateOrder" hook and i have used it. But now i'am trying to get the id of the order that has been submitted. Getting the last order on the database, it's correct but it will maybe cause some problems if multiple order are submitted at the same time. So i have looked at the "params" passed by the hook, but i get only the value "1" (so i think will be a confirm that the order has been processed correctly). Can someone help me about getting the order id (or better the order data) when the "hook" is processed? Thanks everyone Marco PS : my code -> public function hookActionValidateOrder($params){ Logger::AddLog("A new order has been submitted. Data : ".print_r($params)); /* * * More stuff here, but i need the order data * */ } Link to comment Share on other sites More sharing options...
bellini13 Posted November 20, 2015 Share Posted November 20, 2015 Below is the code that actually executes the hook you have registered // Hook validate order Hook::exec('actionValidateOrder', array( 'cart' => $this->context->cart, 'order' => $order, 'customer' => $this->context->customer, 'currency' => $this->context->currency, 'orderStatus' => $order_status )); $params is an array that contains 5 objects, the Order object being one of them. this should get you started... //get the Order object $order = $params['order']; //validate that the Order is an Object and has a valid ID if (!Validate::isLoadedObject($order)) { //do what you need to do $id_order = (int)$order->id; //do some other stuff } 1 Link to comment Share on other sites More sharing options...
marco.predari Posted November 23, 2015 Author Share Posted November 23, 2015 It works, thanks a lot! Link to comment Share on other sites More sharing options...
jhon alba Posted January 31, 2018 Share Posted January 31, 2018 (edited) thanks. Edited January 31, 2018 by jhon alba (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