function hookactionCartSave($params)
{
//print_r($params);
if(!empty($param['cart']))
{
$products = $this->context->cart->getProducts();
if(is_array($products) && count($products)>0){
foreach($products as $key => $val){
$product_id[] = $val['id_product'];
$product_price[] = Product::getPriceStatic($val['id_product'], true, $val['id_product_attribute'], 2, null, false, true, 1);
$product_quantity[] = $val['cart_quantity'];
}
$this->smarty->assign(array(
//'product_id' => implode('|',$product_id),
'product_price' => implode('|',$product_price),
'product_quantity' => implode('|',$product_quantity)
));
//print_r($product_id);
//print_r($product_price);
//print_r($product_quantity);
//print_r($products->id);
return $this->display(__FILE__, 'addcart.tpl');
$this->emptybag();
}
}
}
getting error: Fatal error: Call to a member function getProducts() on null in C:\xampp\htdocs\prestashop\prestashop\modules\blockaffili\blockaffili.php on line 198
1. After this error if i refresh the page then its working fine even if i clicked again.
2. Not Working: Only When i click the add to card button after order confirmation .............. if i continuously click on add to card then its working fine .......................................................
i checked using print_r($param) that this happen when cart array is empty .........