I want this hook to work in category page where a list of products are displayed. The hook is placed in every product item.
I know it sounds uncommon but I have circumstances. Please I just need to solve how to get the product id in this hook?
public function hookDisplayProductInfoGlobal()
{
$idProduct = (int)Tools::getValue('id_product');
echo "Product id = ". $idProduct;
}
result is Product id = 0
You can send the id_product
from the tpl where you are calling the hook, eg:{hook h='displayProductInfoGlobal' product=['id_product' => 123]}
And now in your php take it in the params, eg:
public function hookDisplayProductInfoGlobal($params)
{
$idProduct = (int)$params['id_product'];
echo "Product id = ". $idProduct;
}