Grab The New Year Offer! Flat 20% off now. Use code 'CYM20'

Critical Uncaught Error: Call to a member function Get_Cart_Contents_Count()

Home   »   Critical Uncaught Error: Call to a member function Get_Cart_Contents_Count()

Home Support Ultimate Ecommerce Pro Critical Uncaught Error: Call to a member function Get_Cart_Contents_Count()

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #12096
    angusisok
    Participant

    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 264

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

    #12097
    Shop Manager
    Keymaster

    Hi,

    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

    #12098
    angusisok
    Participant

    No, 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?

    #12102
    Shop Manager
    Keymaster

    Hi,

    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

    #12105
    angusisok
    Participant

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

    #12106
    Shop Manager
    Keymaster

    Hi,

    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

    #12108
    angusisok
    Participant

    Again, I will pass. I want to understand, not have someone do it for me.

    #12109
    angusisok
    Participant

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

    #12113
    Shop Manager
    Keymaster

    Hi,

    Great, It is working for you.

    Message us if you need any other help.

    Thank You

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

Translate »