From e0a417311771408fd6c64808d0a9ffd6ab0518d5 Mon Sep 17 00:00:00 2001 From: honzakadlec Date: Mon, 4 Jan 2021 12:08:31 +0100 Subject: [PATCH] Update class-wc-brands-coupons.php Add check for WC cart != null before accessing it --- includes/class-wc-brands-coupons.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/includes/class-wc-brands-coupons.php b/includes/class-wc-brands-coupons.php index 9ed908d..1090a83 100644 --- a/includes/class-wc-brands-coupons.php +++ b/includes/class-wc-brands-coupons.php @@ -33,6 +33,10 @@ public function __construct() { * @return bool $valid True if coupon is valid, otherwise Exception will be thrown */ public function is_coupon_valid( $valid, $coupon, $discounts = null ) { + if (WC()->cart == null) { + return $valid; + } + $this->set_brand_settings_on_coupon( $coupon ); // Only check if coupon still valid and the coupon has brand restrictions on it.