Jump to content

Hook updateOrderStatus - proper using


florynx

Recommended Posts

Hi,

 

I wish to get running the hookUpdateOrderStatus from my module, to inspect variables etc. (searched the forums and found only http://www.prestashop.com/forums/topic/66366-downloadable-products-question/)

 

The module is installed correctly, but is not doing the job...

 

<?php

if (!defined('_PS_VERSION_'))

exit;

class MyDrm extends Module

{

...

public function install()

{

if (!parent::install() OR !$this->registerHook('updateOrderStatus') )

return false;

return true;

}

...

// at the end of the module, is it correct?

 

function hookUpdateOrderStatus($params) // must be declared public?

{

// If the order status was changed to "Payment accepted"

if ($params['newOrderStatus'] == 2) //I made an initial order and changed manually from backoffice the order status to `Payment accepted` but it is not running forward

{

$sqltitles = 'SELECT *

FROM `'._DB_PREFIX_.'order_detail` od

LEFT JOIN `'._DB_PREFIX_.'product_download` pd ON (od.`product_id`=pd.`id_product`)

WHERE od.`id_order` = '.$params['id_order'].'

AND pd.`active` = 1';

d($sqltitles); // nothing happens, no DIE :-)

$titles = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); // $titles is an array?

p($titles);

 

foreach ($titluri as $titlu) {

OrderDetail::updateDRMdata($titlu); // the function updateDRMdata() I choose to define in /override/classes/OrderDetail.php

}

}

}

}

?>

Appreciate your guiding,

Thanks

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