TECHNICAL ERROR WITH PHP version 8.0.9
-
WordPress version 5.8
Thème actuel : Woodmart Child (version 1.0.0)
Extension actuelle : (version )
PHP version 8.0.9
Détails de l’erreur
======================
Une erreur de type E_ERROR a été causée dans la ligne 1176 du fichier /home/hsyh0079/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.php. Message d’erreur : Uncaught Error: Call to a member function get_cart_contents_count() on null in /home/hsyh0079/public_html/wp-content/themes/woodmart/inc/integrations/woocommerce/template-tags.php:1176
Stack trace:
#0 /home/hsyh0079/public_html/wp-content/themes/woodmart/inc/modules/sticky-toolbar.php(265): woodmart_cart_count()
#1 /home/hsyh0079/public_html/wp-content/themes/woodmart/inc/modules/sticky-toolbar.php(150): woodmart_sticky_toolbar_cart_template()
#2 /home/hsyh0079/public_html/wp-includes/class-wp-hook.php(303): woodmart_sticky_toolbar_template()
#3 /home/hsyh0079/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
#4 /home/hsyh0079/public_html/wp-includes/plugin.php(470): WP_Hook->do_action()
#5 /home/hsyh0079/public_html/wp-includes/general-template.php(3031): do_action()
#6 /home/hsyh0079/public_html/wp-includes/blocks/legacy-widget.php(123): wp_footer()
#7 /home/hsyh0079/public_html/wp-includes/class-wp-hook.php(303): handle_legacy_widget_preview_iframe()
#8 /home/hsyh0079/public_html/wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters()
#9 /home/hsyh0079/public_html/wp-includes/plugin.php(470): WP_Hook->do_action()
#10 /home/hsyh0079/public_html/wp-admin/admin.php(175): do_action()
#11 /home/hsyh0079/public_html/wp-admin/widgets.php(10): require_once(‘/home/hsyh0079/…’)
#12 {main}
thrown
Hello,
Please add this code to the functions.php of the 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
}
We will fix in our nearest update
Best Regards