From 0ee284a382d198b4a03ff3b6b51a6c2cc48d25e2 Mon Sep 17 00:00:00 2001 From: carmenmaymo Date: Thu, 12 Sep 2024 08:27:51 +0200 Subject: [PATCH] Check if array PIWOO-427 --- src/Gateway/Voucher/MaybeDisableGateway.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Gateway/Voucher/MaybeDisableGateway.php b/src/Gateway/Voucher/MaybeDisableGateway.php index 806d142e..8fe1dfa5 100644 --- a/src/Gateway/Voucher/MaybeDisableGateway.php +++ b/src/Gateway/Voucher/MaybeDisableGateway.php @@ -85,7 +85,7 @@ public function shouldRemoveVoucher(): bool * * @return int */ - public function numberProductsWithCategory() + public function numberProductsWithCategory(): int { $cart = WC()->cart; $products = $cart->get_cart_contents(); @@ -107,7 +107,7 @@ public function numberProductsWithCategory() $variationCategory = false; foreach ($products as $product) { $postmeta = get_post_meta($product['product_id']); - $localCategory = array_key_exists( + $localCategory = is_array($postmeta) && array_key_exists( Voucher::MOLLIE_VOUCHER_CATEGORY_OPTION, $postmeta ) ? $postmeta[Voucher::MOLLIE_VOUCHER_CATEGORY_OPTION][0] : false; @@ -140,8 +140,8 @@ public function numberProductsWithCategory() * Check if a product has a default/local category associated * that is not No Category * - * @param string $defaultCategory - * @param string $localCategory + * @param bool|string $defaultCategory + * @param bool|string $localCategory * * @param bool|string $variationCategory * @return bool false if no category