• Resolved clickingclients

    (@clickingclients)


    We’ve the latest version of all plugins.
    We are using Stripe on most orders, even with PayPal installed.

    An error is displayed in the backend when viewing any order, even ones without using PayPal to check out we are getting an error in class-wc-gateway-ppec-plugin.php on line 452:

    Notice: Trying to get property of non-object in /home/customer/www/__OURDOMAIN___/public_html/wp-content/plugins/woocommerce-gateway-paypal-express-checkout/includes/class-wc-gateway-ppec-plugin.php on line 459

    public static function needs_shipping() {
            /* (I've added this TEST which removes the error...)
            if(WC()->cart){
                 $cart_contents  = WC()->cart->cart_contents;
            }
            */
    
    		$cart_contents  = WC()->cart->cart_contents;
    		$needs_shipping = false;
    
    		if ( ! empty( $cart_contents ) ) {
    			foreach ( $cart_contents as $cart_item_key => $values ) {
    				if ( $values['data']->needs_shipping() ) {
    					$needs_shipping = true;
    					break;
    				}
    			}
    		}
    
    		return apply_filters( 'woocommerce_cart_needs_shipping', $needs_shipping );
    	}

    The problem appears to be that when in the admin backend, there is no cart currently available after checkout and so the WC()->cart is null.

    If we deactivate PayPal Checkout the error doesn’t appear.
    OR
    If we deactivate Checkout Field Editor for WooCommerce the error doesn’t appear.

    It seems related to a similar error: https://github.com/woocommerce/woocommerce/issues/23758
    The suggestion is: you need to ways check if is not null first, or even if get_cart is callable.

    I’ve let PayPal plugin know of this, however, I’ve run Plugin Detective against it and found the problem isn’t there when “Checkout Field Editor for WooCommerce” is disabled.

    However, the error is NOT triggered an alert with your plugin turned off.

    We don’t know WHAT is triggering this within your plugin.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author ThemeHigh

    (@themehigh)

    The issue is due to the calling of cart content in the hook “woocommerce_default_address_fields“ directly without checking whether the cart is available or not. It is required to check whether the cart content is available or not.

    The default address field hook (woocommerce_default_address_fields) is used in the get_address_fields() function. In WooCommerce, this function is used to get all the fields available in the billing and shipping section.

    In our plugin, we are also calling the above function to get the all the fields available (default + custom) in the each section (billing and shipping).

    We suggest you to contact the PayPal plugin support inorder to check this issue further. We hope they will be able to help you.

    Thank you!

    Thread Starter clickingclients

    (@clickingclients)

    Thank you. I’ll follow up with them.

    Plugin Author ThemeHigh

    (@themehigh)

    Great!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Error in Admin View Order display – due to WC()->cart === null’ is closed to new replies.