Jump to content

Hook For Cart Rule


Recommended Posts

Hello Guys,


I'd like to know whether there is a hook related to Cart Rule. I am using Prestashop 1.5.4 and here's what i'd like to achive


When a customer submit a voucher code, it will then hook to a module i am developing.


The module basically checks whether the code which just been submitted has a special prefix. If it does, then the module will generate a price rule on the fly (because the voucher code is not yet exist in the system). If the voucher code does not contain any prefix it will just check against the cart rule database (which already exist in the system / has been previously entered by admin).


This might sounds odd, but the module i am creating is actually validating a voucher code generated by another system (external system).


Please let me know whether this is possible.





Link to comment
Share on other sites

Yup, 1.5.4, I read your original post.  I'm checking in 1.5.something (not exactly sure which point release this is).


The important thing however is that it is in the code: Check ObjectModel -> add  -> Hook::exec('actionObject'.get_class($this).'AddBefore', array('object' => $this)); ;)


There are many secret hooks in Prestashop, the code and a debugger are always your friend.

Link to comment
Share on other sites

  • 3 weeks later...

Hello @roja45,


Thanks for your clarification, however it seems that the following code will be called upon, right before creating a new cart rule.

    public function hookActionObjectCartRuleAddBefore()
        echo "testing";

However what i am trying to do is to have something like this :

    public function callThisWhenCustomerSubmitVoucherCodeFromChecktOut()
        /* Place your code here. */

I am wondering whether such hook exists ?



Link to comment
Share on other sites

  • 3 years later...

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...