Skip to content

Commit

Permalink
Merge pull request #938 from mollie/fix/return-type-post-meta-PIWOO-427
Browse files Browse the repository at this point in the history
Check if array PIWOO-427
  • Loading branch information
mmaymo authored Sep 25, 2024
2 parents a0f5f57 + 0ee284a commit b924328
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 b924328

Please sign in to comment.