CRITICAL Uncaught Error: Call to a member function get_cart_contents_count()

Home Support eCommerce Gem CRITICAL Uncaught Error: Call to a member function get_cart_contents_count()

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #17076
    Anonymous
    Inactive

    Hi, almost every day (sometimes several times) I see a following error in woocommerce fatal errors logs:

    CRITICAL Uncaught Error: Call to a member function get_cart_contents_count() on null in /home/users/vactodecz/naturaum.ch/web/wp-content/themes/ecommerce-gem/includes/hooks.php:176

    Stack trace:
    #0 /home/users/vactodecz/naturaum.ch/web/wp-includes/class-wp-hook.php(287): ecommerce_gem_top_header_action()
    #1 /home/users/vactodecz/naturaum.ch/web/wp-includes/class-wp-hook.php(311): WP_Hook->apply_filters()
    #2 /home/users/vactodecz/naturaum.ch/web/wp-includes/plugin.php(478): WP_Hook->do_action()
    #3 /home/users/vactodecz/naturaum.ch/web/wp-content/themes/ecommerce-gem/header.php(44): do_action()
    #4 /home/users/vactodecz/naturaum.ch/web/wp-includes/template.php(730): require_once(‘/home/users/vac…’)
    #5 /home/users/vactodecz/naturaum.ch/web/wp-includes/template.php(676): load_template()
    #6 /home/users/vactodecz/naturaum.ch/web/wp-includes/general-template.php(48): locate_template()
    #7 /home/users/vactodecz/naturaum.ch/web/wp-content/themes/ecommerce-gem/404.php(10): get_header()
    #8 /home/users/vactodecz/naturaum.ch/web/wp in /home/users/vactodecz/naturaum.ch/web/wp-content/themes/ecommerce-gem/includes/hooks.php on line 176

    The topic was once already touched here:
    https://wordpress.org/support/topic/critical-uncaught-error-call-to-a-member-function-get_cart_contents_count/

    But the proposed hint ( =install MailChimp, Contact Form 7, YITH Wishlist, VideoTab) is hardly usable – I have no intention to use these plugins (and these were not mentioned that are required by the theme).

    I absolutely understand such issue might be tricky to handle, as I cannot simulate it on demand. I even dont know whether it has some functional negative impact, as just my customers are triggering several times per day (and I am just seeing its traces in the woocommerce/wp log).

    So I am just registering it to support (and hoping that somebody else is facing it too (and perhaps found some cause/solution)).

    #17126
    nirav
    Keymaster

    Hello There!

    Hope you are doing good!

    We have checked the details and it seems that issue is from woocommerce.
    Please go through https://stackoverflow.com/questions/50252373/call-to-a-member-function-get-cart-contents-count-on-null

    Posible quick fix for this issue is to wrap whole section inside an if condition like:

    echo (is_object( WC()->cart ) ? wp_kses_data( WC()->cart->get_cart_contents_count() ) : ‘’);

    Hope this helps!

    Have a great day ahead!

    Regards,
    Team ProDesigns

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.