Search code examples
phpprestashophookbackoffice

How to access id_order in hook hookDisplayOrderPreview (order preview on orders list in BO)


I see that id_order is not available in $params

public function hookDisplayOrderPreview(array $params) {

        $id_cart = $params['id_cart'];
        $orderID = (int)$params['id_order'];
      /*  $orderID = Tools::getValue('id_order'); */


        $this->context->smarty->assign([
            'order_ID' => $orderID,
            'cartID' => $id_cart
        ]);

        return $this->display(__FILE__, 'displayOrderPreview.tpl');
    }

I have also tried to get it with:

Tools::getValue('id_order')

no luck either. In .tpl file the $orderID is still empty...

Would appreciate any tips. I quess I am missing something..

I am working with Presta 8


Solution

  • You were close! The correct variable is $params['order_id'].

    Details: https://github.com/PrestaShop/example-modules/blob/845fecd90543d07993fe299d2507ad0e232da709/demovieworderhooks/demovieworderhooks.php#L229