Jump to content

Increment a counter on new order


Recommended Posts

Hello everyone,


I wanna increment a counter on every order in my module.


I tried to hook newOrder but it seems that when i order a product by credit card (VADS module or Paypal) the counter does not increment.


So i searched on the official documentation and i found the hook actionPaymentConfirmation which will be executed anytime the order status is changed to "Payment Accepted". But i doesn't wan't it.


actionValidateOrder is newer than newOrder but it's apparently the same.


And OrderConfirmation is not a solution because it's a hook on confirmation page and users doesn't pass necessarily through this page.


So what can i use to increment a counter on order creation ?


Sorry for my bad english  -_-


Thanks by advance,


Link to comment
Share on other sites



Anything that extends ObjectModel in PrestaShop automatically gets hooks for Create Read Update and Delete (CRUD) operations.




Two hooks are ran here:


  • actionObjectAddBefore is executed and passed the object. This is so you can hook ALL objects being added to the database generically.
  • actionObject{$class}AddBefore is executed after and passed the object. This is so you can hook on objects of a specific type, in your case 'Order'

Try registering for the hook "actionObjectOrderAddAfter" which should be called after every order is added. The order may not be validated etc. I am unsure of that.




Link to comment
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...