From 38d861ac1e3537bb71e3500306ca32c06e76fd55 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Mon, 18 Nov 2024 16:48:39 +0200 Subject: [PATCH 1/2] PIPRES-488: added additional validation then adding the product which causes incorrect behavior on some themes --- mollie.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mollie.php b/mollie.php index 4e7c91505..fa475f108 100755 --- a/mollie.php +++ b/mollie.php @@ -32,6 +32,7 @@ use Mollie\Subscription\Install\DatabaseTableInstaller; use Mollie\Subscription\Install\HookInstaller; use Mollie\Subscription\Install\Installer; +use Mollie\Subscription\Config\Config as SubscriptionConfig; use Mollie\Subscription\Provider\SubscriptionProductProvider; use Mollie\Subscription\Repository\LanguageRepository as LanguageAdapter; use Mollie\Subscription\Repository\RecurringOrderRepositoryInterface; @@ -1124,6 +1125,19 @@ public function hookActionAjaxDieCartControllerDisplayAjaxUpdateBefore(array $pa return; } + $isSubscriptionEnabled = Configuration::get(Config::MOLLIE_SUBSCRIPTION_ENABLED); + + $groups = Tools::getValue('group'); + if (!(bool)$isSubscriptionEnabled || !is_array($groups)) { + return; + } + + $subscriptionGroup = Configuration::get(SubscriptionConfig::SUBSCRIPTION_ATTRIBUTE_GROUP); + + if (!in_array($subscriptionGroup, $groups, true)) { + return; + } + $response = json_decode($params['value'], true); $hasError = $response['hasError'] ?? false; From b7328a2be1aa7f8f04c2aba15c2cef4662422ab0 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Tue, 19 Nov 2024 11:05:14 +0200 Subject: [PATCH 2/2] improved attribute group check --- mollie.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mollie.php b/mollie.php index fa475f108..23c6c6b20 100755 --- a/mollie.php +++ b/mollie.php @@ -26,13 +26,13 @@ use Mollie\Repository\PaymentMethodRepositoryInterface; use Mollie\Service\ExceptionService; use Mollie\ServiceProvider\LeagueServiceContainerProvider; +use Mollie\Subscription\Config\Config as SubscriptionConfig; use Mollie\Subscription\Handler\CustomerAddressUpdateHandler; use Mollie\Subscription\Handler\UpdateSubscriptionCarrierHandler; use Mollie\Subscription\Install\AttributeInstaller; use Mollie\Subscription\Install\DatabaseTableInstaller; use Mollie\Subscription\Install\HookInstaller; use Mollie\Subscription\Install\Installer; -use Mollie\Subscription\Config\Config as SubscriptionConfig; use Mollie\Subscription\Provider\SubscriptionProductProvider; use Mollie\Subscription\Repository\LanguageRepository as LanguageAdapter; use Mollie\Subscription\Repository\RecurringOrderRepositoryInterface; @@ -1128,13 +1128,14 @@ public function hookActionAjaxDieCartControllerDisplayAjaxUpdateBefore(array $pa $isSubscriptionEnabled = Configuration::get(Config::MOLLIE_SUBSCRIPTION_ENABLED); $groups = Tools::getValue('group'); - if (!(bool)$isSubscriptionEnabled || !is_array($groups)) { + if (!(bool) $isSubscriptionEnabled || !is_array($groups)) { return; } $subscriptionGroup = Configuration::get(SubscriptionConfig::SUBSCRIPTION_ATTRIBUTE_GROUP); - if (!in_array($subscriptionGroup, $groups, true)) { + // Note: groups = ['attribute_group_id => 'attribute_id'] + if (!array_key_exists($subscriptionGroup, $groups)) { return; }