Home › Support › Ultimate Ecommerce Pro › Critical Uncaught Error: Call to a member function Get_Cart_Contents_Count()
- This topic has 8 replies, 2 voices, and was last updated 4 years, 7 months ago by Shop Manager.
-
AuthorPosts
-
May 19, 2020 at 11:11 pm #12096angusisokParticipant
I keep getting this error `
`CRITICAL Uncaught Error: Call to a member function get_cart_contents_count() on null in C:\Inetpub\vhosts\noexcuses.bz\httpdocs\wp-content\themes\ultimate-ecommerce-shop-pro\template-parts\header\header.php:264
Stack trace:
#0 C:\Inetpub\vhosts\noexcuses.bz\httpdocs\wp-includes\template.php(725): require()
#1 C:\Inetpub\vhosts\noexcuses.bz\httpdocs\wp-includes\template.php(672): load_template(‘C:\\Inetpub\\vhos…’, false)
#2 C:\Inetpub\vhosts\noexcuses.bz\httpdocs\wp-includes\general-template.php(168): locate_template(Array, true, false)
#3 C:\Inetpub\vhosts\noexcuses.bz\httpdocs\wp-content\themes\ultimate-ecommerce-shop-pro\header.php(23): get_template_part(‘template-parts/…’)
#4 C:\Inetpub\vhosts\noexcuses.bz\httpdocs\wp-includes\template.php(723): require_once(‘C:\\Inetpub\\vhos…’)
#5 C:\Inetpub\vhosts\noexcuses.bz\httpdocs\wp-includes\template.php(672): load_template(‘C:\\Inetpub\\vhos…’, true)
#6 C:\Inetpub\vhosts\noexcuses.bz\httpdocs\wp-includes\general-template.php(41): locate_template(Array, true)
#7 C in C:\Inetpub\vhosts\noexcuses.bz\httpdocs\wp-content\themes\ultimate-ecommerce-shop-pro\template-parts\header\header.php on line 264When I look at the actual coding on referenced line 264 that is currently live I get this:
<span class=”cart_icon”><i class=”fa fa-shopping-cart” aria-hidden=”true”><span class=”cart-no”><?php echo wp_kses_data( WC()->cart->get_cart_contents_count() );?></i></span></span>
<div class=”top-cart” id=”cart”>
<div id=”top-add-to-cart>
<div class=”top-cart-inner”>
<?php the_widget( ‘WC_Widget_Cart’, ‘title=’ ); ?>and finally, here is the comparison to the files in the install folder
<span class=”cart_icon”><i class=”fa fa-shopping-cart” aria-hidden=”true”><span class=”cart-no”><?php echo wp_kses_data( WC()->cart->get_cart_contents_count() );?></i></span></span>
<div class=”top-cart” id=”cart”>
<div id=”top-add-to-cart>
<div class=”top-cart-inner”>I’m not sure where to go from here in terms of troubleshooting. Everything seems in order. Both WooCommerce and the Theme are up to date with the latest versions.
May 20, 2020 at 11:47 am #12097Shop ManagerKeymasterHi,
We can check the issue for you, creating a user, assign the job of administrator and email us the URL, login, and password on support@logicalthemes.com
Thank You
May 20, 2020 at 3:17 pm #12098angusisokParticipantNo, I’d rather not, thanks. I would prefer to learn how to fix it myself. Can additionally, I think it would help others that might have this issue in the future if the solution was available instead of having you fix it every time. Can we do that?
May 21, 2020 at 11:32 am #12102Shop ManagerKeymasterHi,
Replace cart ) ? WC()->cart->get_cart_contents_count() : ”;?> code in them folder >> template-parts >> header >> header.php line number 101 on this cart->get_cart_contents_count() );?> code.
Thank You
May 21, 2020 at 5:19 pm #12105angusisokParticipantCouple of problems here with that. First is the line for the code isn’t 101. It is 264. But if I were to go to 101, it would say this: if ( $count2 > 0 ){
and for context here is lines 97 through 106
//’taxonomy’ => //get children of this parent using the catID variable from earlier
);
$child_cats = get_terms( ‘product_cat’ ,$get_children_cats );
$count2 = count($child_cats);
if ( $count2 > 0 ){
echo ‘ <ul class=”dropdown-menu”>’;
foreach( $child_cats as $child_cat ){
//for each child category, get the ID
$childID = $child_cat->cat_ID;
$thumbnail_id2 = get_woocommerce_term_meta( $child_cat->term_id, ‘thumbnail_id’, true );
So I don’t think this is the correct line number that you are referring to. The original posting that I made talked about line 264, which is this:<span class=”cart_icon”><i class=”fa fa-shopping-cart” aria-hidden=”true”><span class=”cart-no”><?php echo wp_kses_data( WC()->cart->get_cart_contents_count() );?></i></span></span>
I believe you are referring to line 264; however, your suggestion reads to replace the following: cart ) ? WC()->cart->get_cart_contents_count() : ”;?> with this line: cart->get_cart_contents_count() );?>
The problem with that is the original line doesn’t include that exact match. I have no line that begins with: cart) unless you are referring to the call for wp_kses_data, is that where I should start replacing from? Please help me to understand.
May 22, 2020 at 10:17 am #12106Shop ManagerKeymasterHi,
We can check the issue for you, creating user, assign the job of administrator and email us the URL, login, and password on support@logicalthemes.com
Thank You
May 22, 2020 at 1:38 pm #12108angusisokParticipantAgain, I will pass. I want to understand, not have someone do it for me.
May 22, 2020 at 4:07 pm #12109angusisokParticipantAnd here is the solution:
I am currently running PHP 7.3.18, since PHP 7.3 release you should use the function is_countable():
So we change line 212 from this:
$count2 = count($child_cats_child);
to this:
$count2 = is_countable($child_cats_child);
and that solves the issue of the uncaught error: Call to a member function.
I hope you can understand as I have come to understand. Thank you for your help.
May 23, 2020 at 11:35 am #12113Shop ManagerKeymasterHi,
Great, It is working for you.
Message us if you need any other help.
Thank You
-
AuthorPosts
- You must be logged in to reply to this topic.