Home Forums WoodMart support forum template-tag error line 1176

template-tag error line 1176

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #319923

    neumeith
    Participant

    Hi,
    my customer gets this error from wordpress – what should we do:

    WordPress-Version 5.8.1
    Aktuelles Theme: Woodmart Child (Version 1.0.0)
    Aktuelles Plugin: (Version )
    PHP-Version 7.4.23

    Fehler-Details
    ==============
    Ein Fehler vom Typ E_ERROR wurde in der Zeile 1176 der Datei /home/customer/www/zuckerfrei.store/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.php verursacht. Fehlermeldung: Uncaught Error: Call to a member function get_cart_contents_count() on null in /home/customer/www/zuckerfrei.store/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.php:1176
    Stack trace:
    #0 /home/customer/www/zuckerfrei.store/public_html/wp-content/themes/woodmart/inc/modules/sticky-toolbar.php(265): woodmart_cart_count()
    #1 /home/customer/www/zuckerfrei.store/public_html/wp-content/themes/woodmart/inc/modules/sticky-toolbar.php(150): woodmart_sticky_toolbar_cart_template()
    #2 /home/customer/www/zuckerfrei.store/public_html/wp-includes/class-wp-hook.php(303): woodmart_sticky_toolbar_template(”)
    #3 /home/customer/www/zuckerfrei.store/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters(NULL, Array)
    #4 /home/customer/www/zuckerfrei.store/public_html/wp-includes/plugin.php(470): WP_Hook->do_action(Array)
    #5 /home/customer/www/zuckerfrei.store/public_html/wp-includes/general-template.php(3031): do_action(‘wp_footer’)
    #6 /home/customer/www/zuckerfrei.store/public_

    #320006

    Luke Nielsen
    Keymaster

    Hello,

    Please, try to add this code to the functions.php file in your child theme

    function woodmart_cart_count() {
    	if ( ! is_object( WC() ) || ! property_exists( WC(), 'cart' ) || ! method_exists( WC()->cart, 'get_cart_contents_count' ) ) {
    		return;
    	}
    
    	$count = WC()->cart->get_cart_contents_count();
    	?>
    		<span class="wd-cart-number<?php echo woodmart_get_old_classes( ' woodmart-cart-number' ); ?>"><?php echo esc_html( $count ); ?> <span><?php echo esc_html( _n( 'item', 'items', $count, 'woodmart' ) ); ?></span></span>
    	<?php
    }

    Kind Regards

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)