Jump to content
tmcca

Wishlist For Phoenix

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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 by LeeFoster

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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. 


Always back up before making changes.

Share this post


Link to post
Share on other sites
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. 


Always back up before making changes.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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. 


Always back up before making changes.

Share this post


Link to post
Share on other sites
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');

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

@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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 by kgtee

Share this post


Link to post
Share on other sites

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-&gt;getOutput()
#3 /xx/s4/catalog/includes/system/versioned/1.0.7.6/osc_template.php(106): cm_navbar-&gt;execute()
#4 /xx/s4/catalog/templates/default/includes/components/template_top.php(46): oscTemplate-&gt;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.

Share this post


Link to post
Share on other sites

@amaische I used this wishlist navbar module

    https://apps.oscommerce.com/cl8JP&amp;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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×