Prestashop Module: hooks and orders
Asked Answered
C

1

5

I am having multiple questions about this topic

As the title states, I am in need to find the correct hook to bind when an order has been placed and the payment was accepted.

1.) Which hook should I bind in my module when an order has been placed (and payed)?

2.) I am under the impression that there is no generalized hook for this, since some payment methods set the order status to 'payed' automatically (like a successful PayPal transaction) while other methodes require the shopowner to manually set the status to 'payed'. Are there any more than just those two that must be called to cover most cases?

3.) Eventhough I am still hoping that there is a generalized hook, if there's none, how would I approach this issue? Bind "actionPaymentConfirmation" aswell as "displayPaymentReturn" to cover both cases?

4.) Why is the hook "actionPaymentConfirmation" never called when I set the order status to "payed" in the backoffice. My code looks like this

public function install() {

   if (!parent::install() || !$this->registerHook("actionPaymentConfirmation")) {
        return false;
    }
    return true;
}

public function actionPaymentConfirmation($params) {
    print_r($params);   // stepping through with XDebug but the function is never being invoked
}

5.) Does anyone know a free module doing something simmilar I can dig into to get a better idea?

6.) Or might it be easier to override Prestashops core classes to tackle my problems? To break it down, I want to execute stuff after an order has been placed and the status is set to payment was accepted or remotely accepted.

Well, I hope I am not asking to much stuff at the same time, but as you can see, I am interested in mastering these things but have some troubles along the way. Have now been trying and especially search for answers for days now without any luck.

Regards!

Coarsen answered 25/11, 2013 at 16:53 Comment(0)
D
10

I assume that you're with PrestaShop 1.5

1 actionValidateOrder (for new order) & actionOrderStatusPostUpdate (here you can check about the "paid" status)

2 Like 1.

3 Like 1.

4 The hook is actionOrderStatusPostUpdate

5

public function install()
{
    return (parent::install()
        AND $this->registerHook('newOrder')
        AND $this->registerHook('actionOrderStatusPostUpdate'));
}

public function hookNewOrder($params)
{
    return $this->hookActionOrderStatusPostUpdate($params);
}

public function hookActionOrderStatusPostUpdate($params)
{
    //$params['newOrderStatus'] // after status changed
    //$params['orderStatus'] // after order is placed
}

6 Look at 5.

Note: actionValidateOrder the new name (alias) of newOrder

Dumm answered 26/11, 2013 at 11:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.