LeeFoster Posted June 18, 2020 Share Posted June 18, 2020 Finally got this on a live site and now getting the below error on the first visit to the site. Quote Fatal error: Uncaught Error: Call to a member function count_contents() on null in /customers/2/b/b/360wargaming.com/httpd.www/includes/modules/navbar_modules/templates/tpl_nb_wish_list.php:3 Stack trace: #0 /customers/2/b/b/360wargaming.com/httpd.www/includes/modules/block_template.php(14): include() #1 /customers/2/b/b/360wargaming.com/httpd.www/includes/modules/navbar_modules/nb_wish_list.php(52): include('/customers/2/b/...') #2 /customers/2/b/b/360wargaming.com/httpd.www/includes/modules/content/navigation/cm_navbar.php(60): nb_wish_list->getOutput() #3 /customers/2/b/b/360wargaming.com/httpd.www/includes/system/versioned/1.0.4.0/osc_template.php(146): cm_navbar->execute() #4 /customers/2/b/b/360wargaming.com/httpd.www/includes/template_top.php(45): oscTemplate->getContent('navigation') #5 /customers/2/b/b/360wargaming.com/httpd.www/index.php(35): require('/customers/2/b/...') #6 {main} thrown in /customers/2/b/b/360wargaming.com/httpd.www/includes/modules/navbar_modules/templates/tpl_nb_wish_list.php on line 3 Any ideas? Or can I just suppress it? Quote Link to comment Share on other sites More sharing options...
burt Posted June 18, 2020 Share Posted June 18, 2020 global $cart in the relevant navbar module. That may lead to other problems or it may fix it. Quote Link to comment Share on other sites More sharing options...
LeeFoster Posted June 18, 2020 Share Posted June 18, 2020 (edited) 14 minutes ago, burt said: That may lead to other problems or it may fix it. Did neither, I'll carry on looking though. The wishlist addon has its class file that contains it's own count_contents function. Edited June 18, 2020 by LeeFoster Quote Link to comment Share on other sites More sharing options...
kgtee Posted June 19, 2020 Share Posted June 19, 2020 When you make wishlist into a hook, I am curious how you ensure the wishlist action is executed before the shopping cart action. This order of execution is important as you do not want shopping cart to act first leaving nothing for the wishlist. Quote Link to comment Share on other sites More sharing options...
♥ecartz Posted June 19, 2020 Share Posted June 19, 2020 20 minutes ago, kgtee said: When you make wishlist into a hook, I am curious how you ensure the wishlist action is executed before the shopping cart action. This order of execution is important as you do not want shopping cart to act first leaving nothing for the wishlist. Put it in the hook before the shopping cart action is processed? This will be a little more complicated in 1.0.7.4, as the shopping cart actions are also processed by a hook. But in 1.0.7.3, there is a hook call immediately prior to the processing of the shopping cart actions. 22 hours ago, LeeFoster said: The wishlist addon has its class file that contains its own count_contents function. Then it seems to be saying that the $wishlist object is not set. I would probably replace it with $_SESSION['wishlist'] and it's possible that it is not triggering the wishlist creation for some reason. Or perhaps it needs to be gated by if (isset($_SESSION['wishlist'])) { somewhere. Quote Always back up before making changes. Link to comment Share on other sites More sharing options...
LeeFoster Posted July 28, 2020 Share Posted July 28, 2020 The upgrade to 1.0.7.5 has caused issues with this add on, is any one interested in working together to get this fixed? Quote Link to comment Share on other sites More sharing options...
♥ecartz Posted July 28, 2020 Share Posted July 28, 2020 2 minutes ago, LeeFoster said: The upgrade to 1.0.7.5 has caused issues with this add on, is any one interested in working together to get this fixed? 1.0.7.5? Or 1.0.7.4? You should be able to just change the hook to run just before the shopping cart actions. I did this recently, so I should probably be able to look up the new hook name/location later. Quote Always back up before making changes. Link to comment Share on other sites More sharing options...
LeeFoster Posted July 28, 2020 Share Posted July 28, 2020 2 minutes ago, ecartz said: 1.0.7.5? Or 1.0.7.4? You should be able to just change the hook to run just before the shopping cart actions. I did this recently, so I should probably be able to look up the new hook name/location later. 1.0.7.5, the issue seems to be with get_products() function Quote Link to comment Share on other sites More sharing options...
♥ecartz Posted July 28, 2020 Share Posted July 28, 2020 But the get_products function hasn't changed since 1.0.7.3 The hook I couldn't remember off hand was hook_shop_system__23_parse_actions and listen_startApplication. Quote Always back up before making changes. Link to comment Share on other sites More sharing options...
LeeFoster Posted July 29, 2020 Share Posted July 29, 2020 16 hours ago, ecartz said: But the get_products function hasn't changed since 1.0.7.3 The hook I couldn't remember off hand was hook_shop_system__23_parse_actions and listen_startApplication. Yeah I think the issue is that the hook I was using has been removed/replaced $OSCOM_Hooks->call('system', 'preActionApp'); Quote Link to comment Share on other sites More sharing options...
amaische Posted October 26, 2020 Share Posted October 26, 2020 Hello, I have Phoenix 1.0.7.7 and I dont know, how to solve the problem " Fatal error: Uncaught Error: Call to a member function count_contents() " in this version. Can you please help me ? best regards A. Maischein Quote Link to comment Share on other sites More sharing options...
kgtee Posted October 26, 2020 Share Posted October 26, 2020 @amaische If the error is correctly " Fatal error: Uncaught Error: Call to a undefined function count_contents() " , then it is likely you have not uploaded the wishlist class file in the " includes/classes " folder. Quote Link to comment Share on other sites More sharing options...
amaische Posted October 26, 2020 Share Posted October 26, 2020 Thank you for the reply and sorry, I copied an pasted the wrong error (this one I have found). The correct error is: Uncaught Error: Call to a member function count_contents() on null in /homepages/42/d33248359/htdocs/s4/catalog/includes/modules/navbar/templates/tpl_nb_wishlist.php wishlist is uploaded in classes. Quote Link to comment Share on other sites More sharing options...
kgtee Posted October 26, 2020 Share Posted October 26, 2020 (edited) The function call has been converted to a session call. You should have this in the template file: Quote <div class="dropdown-menu dropdown-menu-lg-right" aria-labelledby="navDropdownCart"> <?php echo '<a class="dropdown-item" href="' . tep_href_link('wishlist.php') . '">' . sprintf(MODULE_NAVBAR_WISH_LIST_HAS_CONTENTS, $_SESSION['wishList']->count_contents(), $GLOBALS['currencies']->format($_SESSION['wishList']->show_total())) . '</a>'; if ($_SESSION['wishList']->count_contents() > 0) { echo '<div class="dropdown-divider"></div>' . PHP_EOL; $products = $_SESSION['wishList']->get_products(); foreach ($products as $k => $v) { echo sprintf(MODULE_NAVBAR_WISH_LIST_PRODUCT, $v['id'], $v['quantity'], $v['name']); } } ?> </div> Edited October 26, 2020 by kgtee Quote Link to comment Share on other sites More sharing options...
amaische Posted October 27, 2020 Share Posted October 27, 2020 I copied the mentioned <div>...</div> to tpl_nb_wishlist.php in includes/modules/navbar/templates. Now I receive an empty page and inside I can find: <div class="dropdown-menu dropdown-menu-lg-right" aria-labelledby="navDropdownCart"> <br> <b>Warning</b>: Use of undefined constant MODULE_NAVBAR_WISH_LIST_HAS_CONTENTS - assumed 'MODULE_NAVBAR_WISH_LIST_HAS_CONTENTS' (this will throw an Error in a future version of PHP) in <b>/xx/s4/catalog/includes/modules/navbar/templates/tpl_nb_wishlist.php</b> on line <b>4</b><br> <br> <b>Notice</b>: Undefined index: wishList in <b>/xx/s4/catalog/includes/modules/navbar/templates/tpl_nb_wishlist.php</b> on line <b>4</b><br> <br> <b>Fatal error</b>: Uncaught Error: Call to a member function count_contents() on null in /xx/s4/catalog/includes/modules/navbar/templates/tpl_nb_wishlist.php:4 Stack trace: #0 /xx/s4/catalog/includes/modules/block_template.php(14): include() #1 /xx/s4/catalog/includes/modules/navbar/nb_wishlist.php(51): include('/homepages/42/d...') #2 /xx/s4/catalog/includes/modules/content/navigation/cm_navbar.php(60): nb_wishlist->getOutput() #3 /xx/s4/catalog/includes/system/versioned/1.0.7.6/osc_template.php(106): cm_navbar->execute() #4 /xx/s4/catalog/templates/default/includes/components/template_top.php(46): oscTemplate->getContent('navigation') #5 /xx/s4/catalog/templates/default/includes/pages/index.php(13): require('/homepages/42/d...') #6 /xx/s4/catalog/index.php(35): require('/homepages/42/d...') #7 {main} thrown in <b>/xx/s4/catalog/includes/modules/navbar/templates/tpl_nb_wishlist.php</b> on line <b>4</b><br> </div> I dont have anywhere the MODULE_NAVBAR_WISH_LIST_HAST_CONTENTS besides in the copied part. Quote Link to comment Share on other sites More sharing options...
kgtee Posted October 27, 2020 Share Posted October 27, 2020 @amaische I used this wishlist navbar module https://apps.oscommerce.com/cl8JP&wishlist-module-for-modular-navigation-b which is different from yours. This module has the MODULE_NAVBAR_WISH_LIST_HAST_CONTENTS. However, your error "Uncaught Error: Call to a member function count_contents() on null" is more difficult to solve. It can be due to an error (typo?) in the wishlist class. Perhaps you want to check the class functions therein more thoroughly. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.