• Resolved sajeertk

    (@sajeertk)


    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’)

Viewing 7 replies - 1 through 7 (of 7 total)
  • Same here

    PHP Fatal error: Uncaught Error: Call to a member function needs_shipping() on null in /wp-content/plugins/woocommerce-gateway-paypal-express-checkout/includes/class-wc-gateway-ppec-checkout-handler.php:120

    I found it conflict with some other plugin that share same functions/resources “YITH WooCommerce Quick Checkout for Digital Goods Premium”

    Hi there
    it looks like it conflicts with WooCommerce Checkout Field Editor, but I don’t know how to solve this. Help anyone?

    ok, I found a workaround for now.
    The problem was coming from wp-content/plugins/woocommerce-gateway-paypal-express-checkout/includes/class-wc-gateway-ppec-checkout-handler.php on line 120
    so I added on line 120 the following:

    		if (null !== (WC()->cart)){
    			if ( ! WC()->cart->needs_shipping() ) {
    				$not_required_fields = array( 'billing_address_1', 'billing_city', 'billing_state', 'billing_postcode' );
    				foreach ( $not_required_fields as $not_required_field ) {
    					if ( array_key_exists( $not_required_field, $billing_fields ) ) {
    						$billing_fields[ $not_required_field ]['required'] = false;
    					}
    				}
    			}
    		}

    [Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]

    and it seems to work.

    • This reply was modified 7 years, 6 months ago by bdbrown.
    Plugin Contributor Praveen a11n

    (@spraveenitpro)

    Automattic Happiness Engineer

    Glad to hear, for future issues regarding payments You can open a ticket by going to?https://www.WooCommerce.com, then click on?Support > Helpdesk > Create a ticket > Free plugins..

    Have a nice day.

    I also got a fatal error from using this code
    https://github.com/woocommerce/woocommerce/issues/new

    in the “woocommerce/includes/class-wc-countries.php”
    I had problems with the paypal express checkout. It was a required field that wasn’t possible to fill out.
    What I got is this

    Fatal error: Uncaught Error: Call to undefined function wc_gzd_get_hook_priority() in /homepages/10/d622659253/htdocs/clickandbuilds/GentleZeusShop/wp-content/themes/shopkeeper/functions.php:1071 Stack trace: #0 /homepages/10/d622659253/htdocs/clickandbuilds/GentleZeusShop/wp-content/themes/shopkeeper/functions.php(1096): germanized_compatibility() #1 /homepages/10/d622659253/htdocs/clickandbuilds/GentleZeusShop/wp-settings.php(424): include(‘/homepages/10/d…’) #2 /homepages/10/d622659253/htdocs/clickandbuilds/GentleZeusShop/wp-config.php(80): require_once(‘/homepages/10/d…’) #3 /homepages/10/d622659253/htdocs/clickandbuilds/GentleZeusShop/wp-load.php(37): require_once(‘/homepages/10/d…’) #4 /homepages/10/d622659253/htdocs/clickandbuilds/GentleZeusShop/wp-blog-header.php(13): require_once(‘/homepages/10/d…’) #5 /homepages/10/d622659253/htdocs/clickandbuilds/GentleZeusShop/index.php(17): require(‘/homepages/10/d…’) #6 {main} thrown in /homepages/10/d622659253/htdocs/clickandbuilds/GentleZeusShop/wp-content/themes/shopkeeper/functions.php on line 1071

    I reuploaded the original “woocommerce/includes/class-wc-countries.php”
    but the fatal error is still the same ?? Can someone help me out? I don’t know what to do.

    Hi @djakuza
    It doesn’t look related to the main question, so you might want to create a new thread?

    hi @ptitcali
    yes that would be really nice.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Fatal error: Uncaught Error: Call to a member function needs_shipping()’ is closed to new replies.