From a49a37c2eab97ea46b04a58cad746bfc45b12ec2 Mon Sep 17 00:00:00 2001 From: Seghir Nadir Date: Fri, 24 Feb 2023 15:53:11 +0100 Subject: [PATCH] Check for null session before going forward (#8537) --- src/Shipping/ShippingController.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Shipping/ShippingController.php b/src/Shipping/ShippingController.php index 2a20b91ea31..9735f04cc16 100644 --- a/src/Shipping/ShippingController.php +++ b/src/Shipping/ShippingController.php @@ -283,6 +283,10 @@ public function flush_cache( $settings ) { * @return array */ public function filter_taxable_address( $address ) { + + if ( null === WC()->session ) { + return $address; + } // We only need to select from the first package, since pickup_location only supports a single package. $chosen_method = current( WC()->session->get( 'chosen_shipping_methods', array() ) ) ?? ''; $chosen_method_id = explode( ':', $chosen_method )[0];