From 088da882392ae8c9d7f54275d14e2ae609c1a5a8 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Wed, 16 Oct 2024 15:35:13 +0300 Subject: [PATCH 1/3] PIPRES-479: subscription attribute bug fix --- mollie.php | 25 ++++++++++++++++++++++++- upgrade/Upgrade-6.2.4.php | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 upgrade/Upgrade-6.2.4.php diff --git a/mollie.php b/mollie.php index 57969e2a2..170e7b83e 100755 --- a/mollie.php +++ b/mollie.php @@ -27,6 +27,7 @@ use Mollie\Service\ExceptionService; use Mollie\ServiceProvider\LeagueServiceContainerProvider; use Mollie\Subscription\Handler\CustomerAddressUpdateHandler; +use Mollie\Subscription\Config\Config as SubscriptionConfig; use Mollie\Subscription\Handler\UpdateSubscriptionCarrierHandler; use Mollie\Subscription\Install\AttributeInstaller; use Mollie\Subscription\Install\DatabaseTableInstaller; @@ -89,7 +90,7 @@ public function __construct() { $this->name = 'mollie'; $this->tab = 'payments_gateways'; - $this->version = '6.2.3'; + $this->version = '6.2.4'; $this->author = 'Mollie B.V.'; $this->need_instance = 1; $this->bootstrap = true; @@ -1334,6 +1335,11 @@ public function hookActionFrontControllerAfterInit(): void $this->frontControllerAfterInit(); } + public function hookActionObjectAttributeUpdateBefore($params) + { + $a = $params; + } + public function hookActionFrontControllerInitAfter(): void { $this->frontControllerAfterInit(); @@ -1404,4 +1410,21 @@ private function addPreventDeleteErrorMessage(): void $this->context->controller->errors[] = $this->l('You can\'t remove address associated with subscription'); } } + + public function hookActionAttributeSave($params): void + { + if (isset($params['id_attribute']) && (int)$params['id_attribute'] > 0) { + $attribute = new ProductAttribute((int)$params['id_attribute']); + + if (Validate::isLoadedObject($attribute)) { + /** @var ConfigurationAdapter $configuration */ + $configuration = $this->getService(ConfigurationAdapter::class); + + if ((int)$attribute->id_attribute_group === (int) $configuration->get(SubscriptionConfig::SUBSCRIPTION_ATTRIBUTE_GROUP)) { + // Add an error message if it's the Mollie group + $this->context->controller->errors[] = $this->l('New attributes are not compatible with Mollie subscription.'); + } + } + } + } } diff --git a/upgrade/Upgrade-6.2.4.php b/upgrade/Upgrade-6.2.4.php new file mode 100644 index 000000000..1179785f6 --- /dev/null +++ b/upgrade/Upgrade-6.2.4.php @@ -0,0 +1,19 @@ + + * @copyright Mollie B.V. + * @license https://github.com/mollie/PrestaShop/blob/master/LICENSE.md + * + * @see https://github.com/mollie/PrestaShop + */ + +if (!defined('_PS_VERSION_')) { + exit; +} + +function upgrade_module_6_2_4(Mollie $module): bool +{ + return $module->registerHook('actionAttributeSave'); +} From 47af505134f7d548853a4a8266ec340570c4d3c7 Mon Sep 17 00:00:00 2001 From: Gytautas Date: Wed, 16 Oct 2024 15:46:19 +0300 Subject: [PATCH 2/3] changelog updated --- changelog.md | 3 +++ mollie.php | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index eb2c90030..6e3658d68 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,9 @@ ![Mollie](https://www.mollie.nl/files/Mollie-Logo-Style-Small.png) # Changelog # +## Changes in release 6.2.3 ## ++ Subscription attribute editing fix + ## Changes in release 6.2.3 ## + Multi shop improvements with order states + Logging improvements diff --git a/mollie.php b/mollie.php index 170e7b83e..69274f5ae 100755 --- a/mollie.php +++ b/mollie.php @@ -1335,11 +1335,6 @@ public function hookActionFrontControllerAfterInit(): void $this->frontControllerAfterInit(); } - public function hookActionObjectAttributeUpdateBefore($params) - { - $a = $params; - } - public function hookActionFrontControllerInitAfter(): void { $this->frontControllerAfterInit(); From 690e6d019ba60d8d83b2327e582db3b3328a944b Mon Sep 17 00:00:00 2001 From: Gytautas Date: Wed, 16 Oct 2024 16:03:10 +0300 Subject: [PATCH 3/3] php cs fixer --- changelog.md | 2 +- mollie.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/changelog.md b/changelog.md index 6e3658d68..abd14d5e3 100644 --- a/changelog.md +++ b/changelog.md @@ -1,7 +1,7 @@ ![Mollie](https://www.mollie.nl/files/Mollie-Logo-Style-Small.png) # Changelog # -## Changes in release 6.2.3 ## +## Changes in release 6.2.4 ## + Subscription attribute editing fix ## Changes in release 6.2.3 ## diff --git a/mollie.php b/mollie.php index 69274f5ae..286862ead 100755 --- a/mollie.php +++ b/mollie.php @@ -26,8 +26,8 @@ use Mollie\Repository\PaymentMethodRepositoryInterface; use Mollie\Service\ExceptionService; use Mollie\ServiceProvider\LeagueServiceContainerProvider; -use Mollie\Subscription\Handler\CustomerAddressUpdateHandler; 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; @@ -1408,14 +1408,14 @@ private function addPreventDeleteErrorMessage(): void public function hookActionAttributeSave($params): void { - if (isset($params['id_attribute']) && (int)$params['id_attribute'] > 0) { - $attribute = new ProductAttribute((int)$params['id_attribute']); + if (isset($params['id_attribute']) && (int) $params['id_attribute'] > 0) { + $attribute = new ProductAttribute((int) $params['id_attribute']); if (Validate::isLoadedObject($attribute)) { /** @var ConfigurationAdapter $configuration */ $configuration = $this->getService(ConfigurationAdapter::class); - if ((int)$attribute->id_attribute_group === (int) $configuration->get(SubscriptionConfig::SUBSCRIPTION_ATTRIBUTE_GROUP)) { + if ((int) $attribute->id_attribute_group === (int) $configuration->get(SubscriptionConfig::SUBSCRIPTION_ATTRIBUTE_GROUP)) { // Add an error message if it's the Mollie group $this->context->controller->errors[] = $this->l('New attributes are not compatible with Mollie subscription.'); }