Jump to content

Recommended Posts


This may be a noob question but I am wondering if, when using an action hook like, for example, ActionUpdateQuantity, we have to return something in the function hookActionUpdateQuantity.

I mean, when the hook is executed and the public function in the module is called, it processes the code we put inside the function and that's it. I am working on a module on P 1.6 that everytime a product's available stock comes down to 0, it will check the product in a table where I have previously stored an up to date list of our suppliers' products and availability, and, if this product is available for one of these suppliers, the module will set out_of_stock to 1 and allow selling it on the front. 

If, for example, the product with the stock coming down to 0 has got attributes,  I don't want to continue with the process and I want to stop the function working for this product, should I just write something like this?:

if (Product::getProductAttributesIds($params['id_product'])){                  



Or maybe return true;  Is the way of stopping the function what bothers me, and also, what happens if I check everything and finally I set out_of_stock=1 ? Should I finish the function execution with something like return or leave it like that?

I am worried about what happens with the rest of the processes that are functioning at the same time besides my module when it is called. If we check Stockavailable.php we can see that, after Hook::exec('actionUpdateQuantity...) there is still some more code to execute and if this happens during a sale, there will be a lot more things to happen like the order process, updating the customer, etc

I guess these are all parallel processes and this is not that important.

Sorry if I am not explaining myself very well and thanks for any answer.


Share this post

Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More