Home › Support › eCommerce Gem › CRITICAL Uncaught Error: Call to a member function get_cart_contents_count()
- This topic has 1 reply, 2 voices, and was last updated 4 years, 3 months ago by nirav.
-
AuthorPosts
-
September 28, 2020 at 10:15 am #17076AnonymousInactive
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 176The 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)).
October 6, 2020 at 5:19 am #17126niravKeymasterHello 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-nullPosible 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 -
AuthorPosts
- You must be logged in to reply to this topic.