From 4b3f2e74d71e82d777e51623ee7adec4dbb4f97a Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Thu, 24 Oct 2024 15:09:26 +0200 Subject: [PATCH 1/5] fix: Impossible configure Alma if PS Account version is lower 5.0 --- alma/alma.php | 22 +++++++++++++++++++ alma/translations/de.php | 2 +- alma/translations/en.php | 3 ++- alma/translations/es.php | 2 +- alma/translations/fr.php | 6 +++-- alma/translations/it.php | 2 +- alma/translations/nl.php | 2 +- alma/translations/pt.php | 2 +- .../hook/notificationConfiguration.tpl | 4 ++-- 9 files changed, 35 insertions(+), 10 deletions(-) diff --git a/alma/alma.php b/alma/alma.php index e6f7829d..98de3ac9 100644 --- a/alma/alma.php +++ b/alma/alma.php @@ -31,6 +31,7 @@ class Alma extends PaymentModule { const VERSION = '4.4.0'; + const PS_ACCOUNT_VERSION_REQUIRED = '5.0'; public $_path; public $local_path; @@ -149,6 +150,25 @@ public function checkCompatibilityPSModule() } } + /** + * Check if PS Account is installed and up to date, minimal version required 5.0. + * + * @return void + * + * @throws \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException + */ + public function checkPsAccountCompatibility() + { + $psAccountModule = \Module::getInstanceByName('ps_accounts'); + if (!$psAccountModule) { + throw new \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException('[Alma] PS Account is not installed'); + } + + if ($psAccountModule->version < self::PS_ACCOUNT_VERSION_REQUIRED) { + throw new \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException('[Alma] PS Account is not up to date, minimal version required ' . self::PS_ACCOUNT_VERSION_REQUIRED); + } + } + /** * @return array[] */ @@ -604,10 +624,12 @@ public function getContent() * @return bool * * @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException + * @throws \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException */ public function renderPSAccount() { $this->checkCompatibilityPSModule(); + $this->checkPsAccountCompatibility(); $this->setContainer(); try { diff --git a/alma/translations/de.php b/alma/translations/de.php index 0c25ff59..afc562db 100644 --- a/alma/translations/de.php +++ b/alma/translations/de.php @@ -260,7 +260,7 @@ $_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Enter your API key'; $_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Find your API live key on your %1$s Alma dashboard%2$s'; $_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Um den Testmodus zu verwenden, rufen Sie Ihren Test-API-Schlüssel von Ihrem %1$ssandbox dashboard%2$s ab.'; -$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Wir bieten das PrestaShop Account Modul zum Download an'; +$_MODULE['<{alma}prestashop>notificationconfiguration_42deb316427c319fae8ef1e9a2ebfacb'] = 'Wir bieten das PrestaShop Account Modul zum Download an'; $_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'Das Modul %1$sfinden Sie hier%2$s'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Steigern Sie Ihre Leistung und erhalten Sie Einblicke!'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'Indem Sie diese Option akzeptieren, ermöglichen Sie es Alma, die Nutzung Ihrer Zahlungsmittel zu analysieren, [1]mehr Informationen zu erhalten, um[/1] durchzuführen und diese Daten mit Ihnen zu teilen. Sie können [2]jederzeit abbestellen und Ihre Daten[/2] löschen.'; diff --git a/alma/translations/en.php b/alma/translations/en.php index 98e702b2..44375bc4 100644 --- a/alma/translations/en.php +++ b/alma/translations/en.php @@ -260,7 +260,8 @@ $_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Enter your API key'; $_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Find your API live key on your %1$s Alma dashboard%2$s'; $_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'To use Test mode, retrieve your Test API key from your %1$ssandbox dashboard%2$s'; -$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'We offer to download the PrestaShop Account module'; +$_MODULE['<{alma}prestashop>notificationconfiguration_42deb316427c319fae8ef1e9a2ebfacb'] = 'We offer to download the PrestaShop Account module'; +$_MODULE['<{alma}prestashop>notificationconfiguration_9700e091d54b8ff1fafcd27518c75b23'] = 'Link your store to your PrestaShop account to take full advantage of the modules offered by the PrestaShop Marketplace and optimize your experience.'; $_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'You can find the module %1$shere%2$s'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Increase your performance & get insights !'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'By accepting this option, you enable Alma to analyse the usage of your payment methods, [1]get more information to perform[/1] and share this data with you. You can [2]unsubscribe and erase your data[/2] at any moment.'; diff --git a/alma/translations/es.php b/alma/translations/es.php index e278355b..f591737a 100644 --- a/alma/translations/es.php +++ b/alma/translations/es.php @@ -260,7 +260,7 @@ $_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Introduce tu clave API'; $_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Encuentra tu API live key en tu %1$s Alma dashboard%2$s'; $_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Para utilizar el modo de prueba, obtenga su clave de API de prueba en el panel de control de su sandbox %1$s%2$s'; -$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Te proponemos descargar el módulo Cuenta PrestaShop'; +$_MODULE['<{alma}prestashop>notificationconfiguration_42deb316427c319fae8ef1e9a2ebfacb'] = 'Te proponemos descargar el módulo Cuenta PrestaShop'; $_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'Encontrará el módulo %1$saquí%2$s'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Aumenta tu rendimiento y obtén información'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'Al aceptar esta opción, permites a Alma analizar el uso de tus métodos de pago, [1]obtener más información para realizar[/1] y compartir estos datos contigo. Puedes [2]darte de baja y borrar tus datos[/2] en cualquier momento.'; diff --git a/alma/translations/fr.php b/alma/translations/fr.php index 91a161af..b6773c4d 100644 --- a/alma/translations/fr.php +++ b/alma/translations/fr.php @@ -148,7 +148,8 @@ $_MODULE['<{alma}prestashop>admininsurancehelper_7442e29d7d53e549b78d93c46b8cdcfc'] = 'Commandes'; $_MODULE['<{alma}prestashop>insuranceservice_d87aee5118a62a7ff6c21e4ac31006c5'] = 'Par la présente, je reconnais accepter de souscrire à l\'assurance proposée par Alma. Ce faisant, je confirme avoir préalablement pris connaissance de la [notice d\'information valant conditions générales], du [document d\'information sur le produit d\'assurance], et de la [fiche d\'information et de conseil précontractuelle]. J\'y adhère sans réserve et accepte de signer électroniquement les différents documents formant mon contrat, le cas échéant. Je consens expressément à la collecte et à l\'utilisation de mes données personnelles aux fins de la souscription et de la gestion de mon (mes) contrat(s) d\'assurance.'; $_MODULE['<{alma}prestashop>adminalmainsuranceconfiguration_b824200e9b8aca1fbb762d6566ff0cd7'] = 'Votre configuration a été sauvegardée'; -$_MODULE['<{alma}prestashop>adminalmainsuranceconfiguration_4a39c6a33c3441762924914168d2a387'] = 'Erreur lors de la création de la configuration Assurance Alma : %1$s'; +$_MODULE['<{alma}prestashop>adminalmainsuranceconfiguration_a6bf06f186e2fccecad054fd831c2144'] = '[Alma] Erreur sur le produit d\'assurance pendant le changement de configuration : %1$s'; +$_MODULE['<{alma}prestashop>adminalmainsuranceconfiguration_b42688965893bdb7a37cf1197e506e25'] = '[Alma] Erreur de création de configuration sur l\'assurance Alma : %1$s'; $_MODULE['<{alma}prestashop>adminalmainsuranceorders_a66f446516cd125af12bd25073f88b78'] = 'Commandes avec assurance'; $_MODULE['<{alma}prestashop>adminalmainsuranceorders_49414cda71621b3ee718ae5ff40804c5'] = 'Ordonnance Id'; $_MODULE['<{alma}prestashop>adminalmainsuranceorders_63d5049791d9d79d86e9a108b0a999ca'] = 'Référence'; @@ -260,7 +261,8 @@ $_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Entrez votre clé API'; $_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Trouvez votre clé API sur votre tableau de bord %1$s Alma%2$s'; $_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Pour utiliser le mode test, récupérez votre clé API de test dans le tableau de bord de votre sandbox %1$s%2$s'; -$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Nous vous proposons de télécharger le module PrestaShop Account'; +$_MODULE['<{alma}prestashop>notificationconfiguration_42deb316427c319fae8ef1e9a2ebfacb'] = 'Nous vous proposons de télécharger le module PrestaShop Account'; +$_MODULE['<{alma}prestashop>notificationconfiguration_9700e091d54b8ff1fafcd27518c75b23'] = 'Liez votre boutique à votre compte PrestaShop pour profiter pleinement des modules proposés par PrestaShop Marketplace et optimiser votre expérience.'; $_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'Vous pouvez trouver le module %1$sici%2$s'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Augmentez vos performances et obtenez des informations !'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'En acceptant cette option, vous permettez à Alma d\'analyser l\'utilisation de vos moyens de paiement, [1]d\'obtenir plus d\'informations pour effectuer[/1] et de partager ces données avec vous. Vous pouvez à tout moment vous désinscrire [2]et effacer vos données[/2] .'; diff --git a/alma/translations/it.php b/alma/translations/it.php index 51a8b504..e9247b5c 100644 --- a/alma/translations/it.php +++ b/alma/translations/it.php @@ -260,7 +260,7 @@ $_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Inserire la chiave API'; $_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Trovate la vostra chiave API live sul vostro cruscotto %1$s Alma%2$s'; $_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Per utilizzare la modalità Test, recuperare la chiave API Test dalla dashboard di %1$ssandbox%2$s.'; -$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Vi proponiamo di scaricare il modulo Account di PrestaShop'; +$_MODULE['<{alma}prestashop>notificationconfiguration_42deb316427c319fae8ef1e9a2ebfacb'] = 'Vi proponiamo di scaricare il modulo Account di PrestaShop'; $_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'È possibile trovare il modulo %1$squi%2$s'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = 'Aumenta le tue prestazioni e ricevi approfondimenti sulle tue vendite!'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'Attivando questa opzione, permetti ad Alma di analizzare l\'utilizzo dei tuoi metodi di pagamento [1]al fine[/1] di migliorare il servizio e condividerti un approfondimento sui dati analizzati. Puoi [2]annullare l\'iscrizione e cancellare i tuoi dati[/2] in qualsiasi momento.'; diff --git a/alma/translations/nl.php b/alma/translations/nl.php index 083f537a..f8cccb5e 100644 --- a/alma/translations/nl.php +++ b/alma/translations/nl.php @@ -260,7 +260,7 @@ $_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Voer je API-sleutel in'; $_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Vind je API live key op je %1$s Alma dashboard%2$s'; $_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Om de Testmodus te gebruiken, haalt je je Test API-sleutel op van jouw %1$ssandbox dashboard%2$s'; -$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Wij bieden aan om de PrestaShop Account module te downloaden'; +$_MODULE['<{alma}prestashop>notificationconfiguration_42deb316427c319fae8ef1e9a2ebfacb'] = 'Wij bieden aan om de PrestaShop Account module te downloaden'; $_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'Je kunt de module %1$shier vinden%2$s'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Verhoog je prestaties & krijg inzichten!'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'Door deze optie te aanvaarden, stel je Alma in staat het gebruik van je betaalmethoden te analyseren, [1]meer informatie te verkrijgen om beter te presteren[/1] en deze gegevens met jou te delen. Je kunt [2]je op elk moment uitschrijven en je data wissen[/2].'; diff --git a/alma/translations/pt.php b/alma/translations/pt.php index dbc3eb6c..aa34f0d2 100644 --- a/alma/translations/pt.php +++ b/alma/translations/pt.php @@ -260,7 +260,7 @@ $_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Introduza a sua chave API'; $_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Encontre a sua chave de acesso à API no seu painel de controlo %1$s Alma%2$s'; $_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Para utilizar o modo de teste, recupere a sua chave de API de teste a partir do seu painel de controlo da caixa de areia %1$s%2$s'; -$_MODULE['<{alma}prestashop>notificationconfiguration_41d0063d3bb7d3067f46734fac8b27c4'] = 'Oferecemos a possibilidade de descarregar o módulo Conta PrestaShop'; +$_MODULE['<{alma}prestashop>notificationconfiguration_42deb316427c319fae8ef1e9a2ebfacb'] = 'Oferecemos a possibilidade de descarregar o módulo Conta PrestaShop'; $_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'Pode encontrar o módulo %1$saqui%2$s'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Aumente o seu desempenho e obtenha conhecimentos!'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_5b64cb0849dd12ea528c04f2fe66ae4d'] = 'Ao aceitar esta opção, permite à Alma analisar a utilização dos seus métodos de pagamento, [1]obter mais informações para realizar[/1] e partilhar estes dados consigo. Pode [2]cancelar e apagar os seus dados[/2] a qualquer momento.'; diff --git a/alma/views/templates/hook/notificationConfiguration.tpl b/alma/views/templates/hook/notificationConfiguration.tpl index eae46ccf..9d14af07 100644 --- a/alma/views/templates/hook/notificationConfiguration.tpl +++ b/alma/views/templates/hook/notificationConfiguration.tpl @@ -95,10 +95,10 @@ {if isset($suggestPSAccount) && $suggestPSAccount}

- {l s='We offer to download the PrestaShop Account module ' mod='alma'} + {l s='We offer to download the PrestaShop Account module' mod='alma'}

- {l s='Link your store to your PrestaShop account to take full advantage of the modules offered by the PrestaShop Marketplace and optimize your experience.'} + {l s='Link your store to your PrestaShop account to take full advantage of the modules offered by the PrestaShop Marketplace and optimize your experience.' mod='alma'}

{almaDisplayHtml} {l s='You can find the module %1$shere%2$s' sprintf=['', ''] mod='alma'} From 55a7482d45f5ba95ea6e1527f2c4657c32a16b99 Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Thu, 24 Oct 2024 17:44:24 +0200 Subject: [PATCH 2/5] fix: change limited version PS Account since 5.3.0 --- alma/alma.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/alma/alma.php b/alma/alma.php index 98de3ac9..409b864f 100644 --- a/alma/alma.php +++ b/alma/alma.php @@ -31,7 +31,7 @@ class Alma extends PaymentModule { const VERSION = '4.4.0'; - const PS_ACCOUNT_VERSION_REQUIRED = '5.0'; + const PS_ACCOUNT_VERSION_REQUIRED = '5.3.0'; public $_path; public $local_path; From c7abcebdd188c4dcec7ca6983d02714907ec1cce Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Mon, 28 Oct 2024 19:02:17 +0100 Subject: [PATCH 3/5] fix: Review [OLI] renamed function --- alma/alma.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/alma/alma.php b/alma/alma.php index 409b864f..8b5d53bc 100644 --- a/alma/alma.php +++ b/alma/alma.php @@ -131,7 +131,7 @@ public function __construct() * * @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException */ - public function checkCompatibilityPSModule() + public function checkPsAccountPresence() { if (_PS_MODE_DEV_ === true) { throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException('[Alma] Debug mode is activated'); @@ -156,9 +156,11 @@ public function checkCompatibilityPSModule() * @return void * * @throws \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException + * @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException */ public function checkPsAccountCompatibility() { + $this->checkPsAccountPresence(); $psAccountModule = \Module::getInstanceByName('ps_accounts'); if (!$psAccountModule) { throw new \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException('[Alma] PS Account is not installed'); @@ -242,7 +244,7 @@ private function checkCoreInstall($coreInstall) public function install() { try { - $this->checkCompatibilityPSModule(); + $this->checkPsAccountPresence(); $this->setContainer(); $this->getService('alma.ps_accounts_installer')->install(); } catch (\Alma\PrestaShop\Exceptions\CompatibilityPsAccountException $e) { @@ -628,7 +630,6 @@ public function getContent() */ public function renderPSAccount() { - $this->checkCompatibilityPSModule(); $this->checkPsAccountCompatibility(); $this->setContainer(); From 71c2cbb1d5b609089c9e14ac9b54b7259c92bcfc Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Tue, 29 Oct 2024 10:10:58 +0100 Subject: [PATCH 4/5] fix: Review [OLI] rename psAccount to psAccouts --- alma/alma.php | 46 +++++++++---------- .../hook/GetContentHookController.php | 12 ++--- ...p => CompatibilityPsAccountsException.php} | 2 +- alma/views/templates/hook/getContent.tpl | 2 +- .../hook/notificationConfiguration.tpl | 8 ++-- 5 files changed, 35 insertions(+), 35 deletions(-) rename alma/exceptions/{CompatibilityPsAccountException.php => CompatibilityPsAccountsException.php} (60%) diff --git a/alma/alma.php b/alma/alma.php index 8b5d53bc..1edf9aef 100644 --- a/alma/alma.php +++ b/alma/alma.php @@ -129,24 +129,24 @@ public function __construct() /** * @return void * - * @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException + * @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException */ - public function checkPsAccountPresence() + public function checkPsAccountsPresence() { if (_PS_MODE_DEV_ === true) { - throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException('[Alma] Debug mode is activated'); + throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException('[Alma] Debug mode is activated'); } if ( !class_exists(\Symfony\Component\Config\ConfigCache::class) || !class_exists(\PrestaShop\ModuleLibServiceContainer\DependencyInjection\ServiceContainer::class) ) { - throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException('[Alma] Classes don\'t exist for PS Account'); + throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException('[Alma] Classes don\'t exist for PS Account'); } if ( $this->toolsHelper->psVersionCompare('1.6', '<') ) { - throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException('[Alma] Prestashop version lower than 1.6'); + throw new \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException('[Alma] Prestashop version lower than 1.6'); } } @@ -156,17 +156,17 @@ public function checkPsAccountPresence() * @return void * * @throws \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException - * @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException + * @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException */ - public function checkPsAccountCompatibility() + public function checkPsAccountsCompatibility() { - $this->checkPsAccountPresence(); - $psAccountModule = \Module::getInstanceByName('ps_accounts'); - if (!$psAccountModule) { + $this->checkPsAccountsPresence(); + $psAccountsModule = \Module::getInstanceByName('ps_accounts'); + if (!$psAccountsModule) { throw new \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException('[Alma] PS Account is not installed'); } - if ($psAccountModule->version < self::PS_ACCOUNT_VERSION_REQUIRED) { + if ($psAccountsModule->version < self::PS_ACCOUNT_VERSION_REQUIRED) { throw new \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException('[Alma] PS Account is not up to date, minimal version required ' . self::PS_ACCOUNT_VERSION_REQUIRED); } } @@ -244,10 +244,10 @@ private function checkCoreInstall($coreInstall) public function install() { try { - $this->checkPsAccountPresence(); + $this->checkPsAccountsPresence(); $this->setContainer(); $this->getService('alma.ps_accounts_installer')->install(); - } catch (\Alma\PrestaShop\Exceptions\CompatibilityPsAccountException $e) { + } catch (\Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException $e) { \Alma\PrestaShop\Logger::instance()->info($e->getMessage()); } @@ -608,29 +608,29 @@ public function viewAccess() */ public function getContent() { - $suggestPSAccount = false; + $suggestPSAccounts = false; try { - $hasPSAccount = $this->renderPSAccount(); - } catch (\Alma\PrestaShop\Exceptions\CompatibilityPsAccountException $e) { - $hasPSAccount = false; + $hasPSAccounts = $this->renderPSAccounts(); + } catch (\Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException $e) { + $hasPSAccounts = false; } catch (\PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException $e) { - $hasPSAccount = false; - $suggestPSAccount = true; + $hasPSAccounts = false; + $suggestPSAccounts = true; } - return $this->runHookController('getContent', ['hasPSAccount' => $hasPSAccount, 'suggestPSAccount' => $suggestPSAccount]); + return $this->runHookController('getContent', ['hasPSAccounts' => $hasPSAccounts, 'suggestPSAccounts' => $suggestPSAccounts]); } /** * @return bool * - * @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountException + * @throws \Alma\PrestaShop\Exceptions\CompatibilityPsAccountsException * @throws \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException */ - public function renderPSAccount() + public function renderPSAccounts() { - $this->checkPsAccountCompatibility(); + $this->checkPsAccountsCompatibility(); $this->setContainer(); try { diff --git a/alma/controllers/hook/GetContentHookController.php b/alma/controllers/hook/GetContentHookController.php index 2b4bcc58..b14bec9f 100644 --- a/alma/controllers/hook/GetContentHookController.php +++ b/alma/controllers/hook/GetContentHookController.php @@ -206,7 +206,7 @@ public function processConfiguration() if ((empty($liveKey) && ALMA_MODE_LIVE == $apiMode) || (empty($testKey) && ALMA_MODE_TEST == $apiMode)) { $this->context->smarty->assign('validation_error', "missing_key_for_{$apiMode}_mode"); $this->context->smarty->assign([ - 'suggestPSAccount' => false, + 'suggestPSAccounts' => false, ]); $this->hasKey = false; @@ -540,8 +540,8 @@ public function renderForm() $this->assignSmartyAlertClasses(); $this->context->smarty->assign('tip', 'fill_api_keys'); - $this->context->smarty->assign('suggestPSAccount', false); - $this->context->smarty->assign('hasPSAccount', false); + $this->context->smarty->assign('suggestPSAccounts', false); + $this->context->smarty->assign('hasPSAccounts', false); $extraMessage = $this->module->display($this->module->file, 'getContent.tpl'); } @@ -829,9 +829,9 @@ public function needsAPIKey() public function run($params) { $this->context->smarty->assign([ - 'hasPSAccount' => $params['hasPSAccount'], + 'hasPSAccounts' => $params['hasPSAccounts'], 'updated' => true, - 'suggestPSAccount' => $params['suggestPSAccount'], + 'suggestPSAccounts' => $params['suggestPSAccounts'], ]); $this->assignSmartyAlertClasses(); @@ -863,7 +863,7 @@ public function run($params) $messages = ''; } - if ($params['hasPSAccount'] || $params['suggestPSAccount']) { + if ($params['hasPSAccounts'] || $params['suggestPSAccounts']) { $messages = $this->module->display($this->module->file, 'getContent.tpl'); } diff --git a/alma/exceptions/CompatibilityPsAccountException.php b/alma/exceptions/CompatibilityPsAccountsException.php similarity index 60% rename from alma/exceptions/CompatibilityPsAccountException.php rename to alma/exceptions/CompatibilityPsAccountsException.php index 8e459d87..2c1c115b 100644 --- a/alma/exceptions/CompatibilityPsAccountException.php +++ b/alma/exceptions/CompatibilityPsAccountsException.php @@ -6,6 +6,6 @@ exit; } -class CompatibilityPsAccountException extends AlmaException +class CompatibilityPsAccountsException extends AlmaException { } diff --git a/alma/views/templates/hook/getContent.tpl b/alma/views/templates/hook/getContent.tpl index e82dbc41..e4ef6b7e 100644 --- a/alma/views/templates/hook/getContent.tpl +++ b/alma/views/templates/hook/getContent.tpl @@ -98,7 +98,7 @@ {$validation_error|escape:'htmlall':'UTF-8'} {/if}
-{elseif isset($tip) && (!isset($hasPSAccount) && !$hasPSAccount) || _PS_MODE_DEV_} +{elseif isset($tip) && (!isset($hasPSAccounts) && !$hasPSAccounts) || _PS_MODE_DEV_} {include file="./_partials/notificationFirstInstallation.tpl"} {/if} {if isset($updated) && $updated} diff --git a/alma/views/templates/hook/notificationConfiguration.tpl b/alma/views/templates/hook/notificationConfiguration.tpl index 9d14af07..e28c3792 100644 --- a/alma/views/templates/hook/notificationConfiguration.tpl +++ b/alma/views/templates/hook/notificationConfiguration.tpl @@ -20,7 +20,7 @@ * @copyright 2018-2024 Alma SAS * @license https://opensource.org/licenses/MIT The MIT License *} -{if isset($hasPSAccount) && $hasPSAccount} +{if isset($hasPSAccounts) && $hasPSAccounts}
{if isset($hasKey) && !$hasKey} {include file="./_partials/notificationFirstInstallation.tpl"} @@ -73,8 +73,8 @@ {if isset($hasKey) && !$hasKey} {/if} {/if} -{if isset($suggestPSAccount) && $suggestPSAccount} +{if isset($suggestPSAccounts) && $suggestPSAccounts}

{l s='We offer to download the PrestaShop Account module' mod='alma'} From 6c6cfceb3861d24b620d060d9ed46244c4ea080e Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Tue, 29 Oct 2024 15:18:19 +0100 Subject: [PATCH 5/5] fix: woding notification with update module --- alma/alma.php | 6 +++--- alma/translations/en.php | 2 +- alma/translations/fr.php | 2 +- alma/views/templates/hook/notificationConfiguration.tpl | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/alma/alma.php b/alma/alma.php index 1edf9aef..4c440e08 100644 --- a/alma/alma.php +++ b/alma/alma.php @@ -31,7 +31,7 @@ class Alma extends PaymentModule { const VERSION = '4.4.0'; - const PS_ACCOUNT_VERSION_REQUIRED = '5.3.0'; + const PS_ACCOUNTS_VERSION_REQUIRED = '5.3.0'; public $_path; public $local_path; @@ -166,8 +166,8 @@ public function checkPsAccountsCompatibility() throw new \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException('[Alma] PS Account is not installed'); } - if ($psAccountsModule->version < self::PS_ACCOUNT_VERSION_REQUIRED) { - throw new \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException('[Alma] PS Account is not up to date, minimal version required ' . self::PS_ACCOUNT_VERSION_REQUIRED); + if ($psAccountsModule->version < self::PS_ACCOUNTS_VERSION_REQUIRED) { + throw new \PrestaShop\PsAccountsInstaller\Installer\Exception\ModuleNotInstalledException('[Alma] PS Account is not up to date, minimal version required ' . self::PS_ACCOUNTS_VERSION_REQUIRED); } } diff --git a/alma/translations/en.php b/alma/translations/en.php index 44375bc4..3364d509 100644 --- a/alma/translations/en.php +++ b/alma/translations/en.php @@ -260,7 +260,7 @@ $_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Enter your API key'; $_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Find your API live key on your %1$s Alma dashboard%2$s'; $_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'To use Test mode, retrieve your Test API key from your %1$ssandbox dashboard%2$s'; -$_MODULE['<{alma}prestashop>notificationconfiguration_42deb316427c319fae8ef1e9a2ebfacb'] = 'We offer to download the PrestaShop Account module'; +$_MODULE['<{alma}prestashop>notificationconfiguration_b040aba3ff898146cd8c1fb8cfd04daf'] = 'We offer to download or update the PrestaShop Account module (minimum required version %1$s)'; $_MODULE['<{alma}prestashop>notificationconfiguration_9700e091d54b8ff1fafcd27518c75b23'] = 'Link your store to your PrestaShop account to take full advantage of the modules offered by the PrestaShop Marketplace and optimize your experience.'; $_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'You can find the module %1$shere%2$s'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Increase your performance & get insights !'; diff --git a/alma/translations/fr.php b/alma/translations/fr.php index b6773c4d..bb399bb4 100644 --- a/alma/translations/fr.php +++ b/alma/translations/fr.php @@ -261,7 +261,7 @@ $_MODULE['<{alma}prestashop>notificationconfiguration_cf5ec9fb9f7214a3db82a5a39fec5b48'] = 'Entrez votre clé API'; $_MODULE['<{alma}prestashop>notificationconfiguration_055f421849c2a1c32b885c95540f827c'] = 'Trouvez votre clé API sur votre tableau de bord %1$s Alma%2$s'; $_MODULE['<{alma}prestashop>notificationconfiguration_53b458e8453e3694811e61c96527d638'] = 'Pour utiliser le mode test, récupérez votre clé API de test dans le tableau de bord de votre sandbox %1$s%2$s'; -$_MODULE['<{alma}prestashop>notificationconfiguration_42deb316427c319fae8ef1e9a2ebfacb'] = 'Nous vous proposons de télécharger le module PrestaShop Account'; +$_MODULE['<{alma}prestashop>notificationconfiguration_b040aba3ff898146cd8c1fb8cfd04daf'] = 'Nous vous proposons de télécharger ou de mettre à jour le module PrestaShop Account (version minimale requise %1$s)'; $_MODULE['<{alma}prestashop>notificationconfiguration_9700e091d54b8ff1fafcd27518c75b23'] = 'Liez votre boutique à votre compte PrestaShop pour profiter pleinement des modules proposés par PrestaShop Marketplace et optimiser votre expérience.'; $_MODULE['<{alma}prestashop>notificationconfiguration_6997dde298b14fbf6a7c95bd39fe8dc4'] = 'Vous pouvez trouver le module %1$sici%2$s'; $_MODULE['<{alma}prestashop>notificationshareofcheckout_a6b0ef107f0d278df612764187bbdece'] = ' Augmentez vos performances et obtenez des informations !'; diff --git a/alma/views/templates/hook/notificationConfiguration.tpl b/alma/views/templates/hook/notificationConfiguration.tpl index e28c3792..d6bccf4c 100644 --- a/alma/views/templates/hook/notificationConfiguration.tpl +++ b/alma/views/templates/hook/notificationConfiguration.tpl @@ -95,7 +95,7 @@ {if isset($suggestPSAccounts) && $suggestPSAccounts}

- {l s='We offer to download the PrestaShop Account module' mod='alma'} + {l s='We offer to download or update the PrestaShop Account module (minimum required version %1$s)' sprintf=[Alma::PS_ACCOUNTS_VERSION_REQUIRED] mod='alma'}

{l s='Link your store to your PrestaShop account to take full advantage of the modules offered by the PrestaShop Marketplace and optimize your experience.' mod='alma'}