Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if array PIWOO-427 #938

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading