Cart Fatal error in attempt to call get_tax_class() method
-
Hello there,
I have an issue that keep poping in my logs regarding the WC_Cart class, here is the error in my logs :2024-01-10T09:06:31+00:00 CRITICAL Uncaught Error: Call to a member function get_tax_class() on null in /var/www/vhosts/mywebsite.com/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php:232 Stack trace: #0 /var/www/vhosts/mywebsite.com/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(658): WC_Cart_Totals->get_items_from_cart() #1 /var/www/vhosts/mywebsite.com/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(150): WC_Cart_Totals->calculate_item_totals() #2 /var/www/vhosts/mywebsite.com/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php(141): WC_Cart_Totals->calculate() #3 /var/www/vhosts/mywebsite.com/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-cart.php(1408): WC_Cart_Totals->__construct() #4 /var/www/vhosts/mywebsite.com/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-cart.php(1367): WC_Cart->calculate_totals() #5 /var/www/vhosts/mywebsite.com/httpdocs/wp-content/themes/salient/nectar/woo/cart.php(157): WC_Cart->set_quantity() #6 /var/www/vhosts/mywebsite.com/httpdocs/wp-includes/class-wp-hook.php(324): Nectar_Woo_Cart::update_cart_quantity() #7 /var/www/vhosts/mywebsite.com/httpdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #8 /var/www/vhosts/mywebsite.com/httpdocs/wp-includes/plugin.php(517): WP_Hook->do_action() #9 /var/www/vhosts/mywebsite.com/httpdocs/wp-admin/admin-ajax.php(203): do_action() #10 {main} thrown dans /var/www/vhosts/mywebsite.com/httpdocs/wp-content/plugins/woocommerce/includes/class-wc-cart-totals.php à la ligne 232
This seems to be related to a method called get_tax_class() receiving a null object thus leading to an error because the get_items_from_cart(), calculate_item_totals(), calculate(), and so on… cannot be executed since get_tax_class() is returning null.
Do you know what could be causing the issue ? Does an item could have a null tax value ? If so is there anything that I could do to avoid getting this error ? For instance checking prior to execute this methos if my $object->get_tax_class() isset ?
Thanks in advance for your replies,
Have a great day ??
Paul
- The topic ‘Cart Fatal error in attempt to call get_tax_class() method’ is closed to new replies.