[email protected] Posted March 29, 2015 Share Posted March 29, 2015 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 ......... Link to comment Share on other sites More sharing options...
PascalVG Posted March 30, 2015 Share Posted March 30, 2015 Maybe test if cart is defined: if (isset($this->context->cart)) { $products = $this->context->cart->getProducts(); ... Link to comment Share on other sites More sharing options...
[email protected] Posted March 30, 2015 Author Share Posted March 30, 2015 Thanks I will try and reply soon Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now