Results 1 to 10 of 14

Hybrid View

  1. #1
    Join Date
    Mar 2007
    Posts
    112
    Plugin Contributions
    0

    Default Fatal error when calling count_contents in checkout

    I just looked into a site's error log and noticed the following error has been occurring since the site went "live" in July:

    "Call to a member function count_contents() on a non-object in /xxxxxxxx/includes/modules/sideboxes/shopping_cart.php on line 24"

    The lines from shopping_cart.php the error refers to are:

    Code:
    case (SHOW_SHOPPING_CART_BOX_STATUS == '2'):
          if ( ( ($_SESSION['cart']->count_contents() > 0) || (isset($_SESSION['customer_id']) && zen_user_has_gv_account($_SESSION['customer_id']) > 0) ) && ($_GET['main_page'] != FILENAME_SHOPPING_CART) ) {
            $show_shopping_cart_box = true;
          } else {
            $show_shopping_cart_box = false;
          }
          break;
    Does anyone know what this means? Did the user see a "fatal error" message? Did the user's order go into the basket instead of being processed? Is there something I can do to prevent this?

    I did a search on "count_contents", but didn't find anything useful. If anyone can steer me in the right direction on this, I would really appreciate it. Thanks!
    RAB

    Why is it I'm always surprised when something actually works?

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Fatal error when calling count_contents in checkout

    What addons/contributions do you have installed?
    What sorts of customizations have you made to your site?
    Can you trigger the error by doing a test purchase? What do *you* see on-screen when the error shows up in the logs while you're shopping?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Mar 2007
    Posts
    112
    Plugin Contributions
    0

    Default Re: Fatal error when calling count_contents in checkout

    Hi Doc,

    Quite frankly, the client and I thought the site was running just fine. We did a lot of pretty intensive testing before going "live" and never encountered a fatal error. When the site went live, we had some problems with orders getting processed (approved) by Authorize.net but then going into the basket instead of completing. Talking with you and others about this led us to install the External Order ID Generator mod, and another fix you did to get around the apostrophe in the name problem. But no one reported, and we never saw, any fatal errors. The first time I saw it was when I looked at the error log today, and it showed the error had been occurring pretty regularly since July 29!

    Mods we've installed include:

    Add Custs from Admin
    Admin Profiles
    Capitalize Signup Fields
    Captcha
    Email Address Exporter
    Email Archive Manager
    Export Shipping Info
    External Order ID Generator
    Super Orders

    I didn't do a lot of coding customization - don't know php well enough for that. Since I just discovered the existance of the error, I'll start testing on my local site to see if I can reproduce.

    I have to admit that this is very discouraging as we all thought the site was doing great. Can I assume that thie error would have stopped the user from continuing whatever they were doing - that would be depressing!
    RAB

    Why is it I'm always surprised when something actually works?

  4. #4
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Fatal error when calling count_contents in checkout

    Quote Originally Posted by rbobzin View Post
    Can I assume that thie error would have stopped the user from continuing whatever they were doing
    Maybe. Maybe not.
    Usually a fatal error will abort subsequent page processing. If your shopping-cart sidebox is on the right-hand column, then it's possible that the rest of the side boxes on the page just simply didn't get drawn, and no error message was shown.

    The only reason why that error should appear is if there is no shopping cart object set ... and the only reason for $_SESSION['cart'] to not be set is if something has specifically unset() it, since that object is created before any page-specific processing ever starts. Hence the question about addons/contributions/customizations.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Mar 2007
    Posts
    112
    Plugin Contributions
    0

    Default Re: Fatal error when calling count_contents in checkout

    The cart is indeed the last box in the right column, so maybe customers didn't see the error code, but what coulde have unset the cart in the first place? I'm not sure any of the add-on modules would have any effect on that, except possibly the External Order ID Generator - but that mod fixed a major problem, so I'm really hoping that's not it.

    I did a search for files with $_SESSION['cart'] in them to see if there might be any that I remember editing, and there are a couple that look a bit familiar, so will now compare them with the originals. (Although I'm not sure I'll know what to do after that!)

    In the meantime, the error keeps on happening - according to the error log, 7 times today already.

    [13-Nov-2007 02:04:02]
    [13-Nov-2007 02:41:14]
    [13-Nov-2007 03:58:58]
    [13-Nov-2007 07:16:33]
    [13-Nov-2007 07:18:05]
    [13-Nov-2007 08:52:02]
    [13-Nov-2007 09:05:06]

    And that also looks a little weird - 95% of the site's users are college students, and these times seem a little too early in the morning to me. Is there any way I can record users sessions, try to match sessions with errors, then contact the users to find out what happened?

    This thing really has me bugged, so I much appreciate your help!
    RAB

    Why is it I'm always surprised when something actually works?

  6. #6
    Join Date
    Mar 2007
    Posts
    112
    Plugin Contributions
    0

    Default Re: Fatal error when calling count_contents in checkout

    OK, just compared all the files with $_SESSION['cart'] in them, and all were identical except these 3:

    includes/classes/order.php - 3 changes made by External Order ID Generator

    includes/modules/qps/create_account.php - 2 changes re: anti-robot registration (I think this was a Dr. Byte fix?)

    includes/templates/qps/common/tpl_header.php - I moved the navMainWrapper div to the bottom of the page (based on reading how to do that in one of the forums)

    So, unless I screwed up in the tpl_header.php file, I don't think any customizations are at fault. Now what?
    RAB

    Why is it I'm always surprised when something actually works?

  7. #7
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: Fatal error when calling count_contents in checkout

    Quote Originally Posted by rbobzin View Post
    The cart is indeed the last box in the right column, so maybe customers didn't see the error code
    Do *you* always see the shopping-cart sidebox? It only appears if there is something in the cart.

    Oh, and if the drawing of the right column dies due to an error, the site footer won't show either.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Replies: 6
    Last Post: 15 Oct 2013, 08:33 PM
  2. Replies: 15
    Last Post: 27 Sep 2013, 05:29 PM
  3. Error when calling Sidebox Anywhere Mod
    By Jerry5763837 in forum All Other Contributions/Addons
    Replies: 2
    Last Post: 12 Dec 2009, 03:51 AM
  4. Replies: 1
    Last Post: 21 Jan 2009, 04:36 PM
  5. Fatal error: Using $this when not in object context (one-page-checkout)
    By gsdcypher in forum All Other Contributions/Addons
    Replies: 14
    Last Post: 28 Feb 2008, 08:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg