Skip to content

Commit

Permalink
Check if array PIWOO-427
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Sep 12, 2024
1 parent 228260e commit 0ee284a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Gateway/Voucher/MaybeDisableGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0ee284a

Please sign in to comment.