Fatal error: Uncaught Error: Call to a member function needs_shipping()
-
Hi,
I am getting below Fatal error when calling WC_Countries->get_address_fields(‘SE’, ‘billing_’) from an admin settings page where the cart object is not available or NULL.
You have hooked a function called “filter_billing_fields” to the filter hook “woocommerce_billing_fields”. And in that hooked function you are calling WC()->cart->needs_shipping() function, this throws the error when the cart object is null. There are places where “woocommerce_billing_fields” hook is invoked and the cart object is not available there such as WC_Countries->get_address_fields(‘SE’, ‘billing_’).
Fatal error: Uncaught Error: Call to a member function needs_shipping() on null in /home/makeitst/private_html/makeitstockholm.info/wp-content/plugins/woocommerce-gateway-paypal-express-checkout/includes/class-wc-gateway-ppec-checkout-handler.php:120
Stack trace: #0 /home/makeitst/private_html/makeitstockholm.info/wp-includes/class-wp-hook.php(300): WC_Gateway_PPEC_Checkout_Handler->filter_billing_fields(Array)
#1 /home/makeitst/private_html/makeitstockholm.info/wp-includes/plugin.php(203): WP_Hook->apply_filters(Array, Array)
#2 /home/makeitst/private_html/makeitstockholm.info/wp-content/plugins/woocommerce/includes/class-wc-countries.php(1136): apply_filters(‘woocommerce_bil…’, Array, ‘SE’)
- The topic ‘Fatal error: Uncaught Error: Call to a member function needs_shipping()’ is closed to new replies.