Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prestashop: changing order status in hookActionOrderStatusUpdate

I'am developing module, which after „Payment Accepted“ state executs it's own process and if everything ok - changes order state to Shipped. For that I'am using hookActionOrderStatusUpdate:

public function hookActionOrderStatusUpdate($params)
{
  if($params['newOrderStatus']->id == 2)
        {
           if(!$this->doSomething())
              return false;            
        }
    return /*function for changing order's state*/;
}

But problem is, that new order status changes before „Payment Accepted“. Example:

  1. Waiting for bankwire payment
  2. Delivered
  3. Payment Accepted

Does anyone know how to reslove that problem? P. S. tried hookActionOrderStatusPostUpdate. PS 1.6.0.9

like image 460
user2104323 Avatar asked Oct 17 '25 11:10

user2104323


1 Answers

I had similar problem and I used combination of hookActionOrderStatusUpdate and hookActionOrderHistoryAddAfter.

Reason for that is that hookActionOrderHistoryAddAfter really can add another status after "paid" status. And hookActionOrderStatusUpdate adds its before "shipped", but hookActionOrderHistoryAddAfter does not know about status which going to be set. So it does looks like this:

class MikolaHooks extends Module
{

    public $newOrderStatusId = NULL;
    public function hookActionOrderStatusUpdate($params) {
       $this->newOrderStatusId = $params['newOrderStatus']->id;
    }

    public function hookActionOrderHistoryAddAfter($params) ....
like image 144
user3759015 Avatar answered Oct 20 '25 00:10

user3759015



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!