From 1166f79009c83de7e51890678a555ade890ceada Mon Sep 17 00:00:00 2001 From: Carine Bonnafous Date: Fri, 14 Jun 2024 09:57:44 +0200 Subject: [PATCH 01/10] chore(Taskfile): Fix displayed workflow url --- Taskfile.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 224ccf3c..8f9748aa 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -119,10 +119,11 @@ tasks: desc: Create a release pull request cmds: - gh workflow run release-pull-request.yml - - sleep 2 + - cmd: sleep 2 + silent: true - cmd: echo "Release pull request created, check out https://github.com/alma/{{.REPOSITORY}}/pulls?q=is%3Aopen+is%3Apr+label%3Arelease" silent: true - - cmd: echo "If no pull request is created, check out https://github.com/alma/{{.REPOSITORY}}/actions/workflows/release-pull-request.yml." + - cmd: echo "If no pull request is created, check out https://github.com/alma/{{.REPOSITORY}}/actions/workflows/release-pull-request.yml" silent: true - cmd: echo "Please, review and merge the pull request." silent: true @@ -140,10 +141,11 @@ tasks: Please provide a changelog message. Example: `task hotfix CHANGELOG_MESSAGE='This is a message'`. cmds: - gh workflow run hotfix-pull-request.yml -F changelog-message='{{.CHANGELOG_MESSAGE}}' - - sleep 2 + - cmd: sleep 2 + silent: true - cmd: echo "Hotfix pull request created, check out https://github.com/alma/{{.REPOSITORY}}/pulls?q=is%3Aopen+is%3Apr+label%3Ahotfix" silent: true - - cmd: echo "If no pull request is created, check out https://github.com/alma/{{.REPOSITORY}}/actions/workflows/hotfix-pull-request.yml." + - cmd: echo "If no pull request is created, check out https://github.com/alma/{{.REPOSITORY}}/actions/workflows/hotfix-pull-request.yml" silent: true - cmd: echo "Please, review and merge the pull request." silent: true From 69e19eb7b9bb59df1013876e427615cfaff6d505 Mon Sep 17 00:00:00 2001 From: Carine Bonnafous Date: Tue, 18 Jun 2024 12:20:01 +0200 Subject: [PATCH 02/10] chore(pre-commit): Allow release branch name --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f464b5e1..e10333ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -58,4 +58,4 @@ repos: hooks: - id: check-branch-name args: - - "-r^((chore|ci|dependabot|devx|docs|feature|fix|hotfix|hotfix-backport|infra|other|perf|refactor|security|test)\/.+|(snyk)-.+|main|develop|HEAD)$$" + - "-r^((chore|ci|dependabot|devx|docs|feature|fix|release|hotfix|hotfix-backport|infra|other|perf|refactor|security|test)\/.+|(snyk)-.+|main|develop|HEAD)$$" From 8cccf2a23315d85c62678e3e6443986ccddcde02 Mon Sep 17 00:00:00 2001 From: Carine Bonnafous Date: Fri, 21 Jun 2024 10:39:54 +0200 Subject: [PATCH 03/10] chore(Taskfile): use task:test to be aligned with other repositories --- .github/workflows/ci.yaml | 2 +- Taskfile.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4398d394..7c10ef62 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -45,6 +45,6 @@ jobs: - name: Run unit Tests and Coverage if: ${{ !contains(github.event.pull_request.labels.*.name, 'hotfix') }} - run: task test:coverage + run: task test env: XDEBUG_MODE: coverage diff --git a/Taskfile.yml b/Taskfile.yml index 8f9748aa..86f33fc8 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -15,7 +15,7 @@ tasks: cmds: - docker compose build prestashop - test:coverage: + test: desc: Execute Unit Tests with coverage deps: - docker:build From 74fbdaa2ca75aa064e53cf3495008ddebc94534d Mon Sep 17 00:00:00 2001 From: Carine Bonnafous Date: Fri, 21 Jun 2024 10:53:20 +0200 Subject: [PATCH 04/10] chore(Taskfile): Add a task to install pre-commits --- Taskfile.yml | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index 86f33fc8..aa033bf6 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -10,6 +10,34 @@ tasks: cmds: - task -l + brew: + preconditions: + - sh: brew -v + msg: 'This task requires `brew`. Please refer to this documentation: https://brew.sh/' + + pre-commit: + desc: Install pre-commit tool + internal: true + deps: [brew] + status: + - pre-commit --version + cmds: + - brew install pre-commit + + install:pre-commit: + desc: Install and set up pre-commit hooks + deps: [pre-commit] + cmds: + - pre-commit install --hook-type pre-commit --hook-type commit-msg + + install:tools: + desc: Composer install of tools + sources: + - alma/composer.json + - alma/composer.lock + cmds: + - composer install --optimize-autoloader --working-dir=alma + docker:build: desc: Build prestashop docker image cmds: @@ -35,14 +63,6 @@ tasks: cmds: - rm -rf ./dist - install-tools: - desc: Composer install of tools - sources: - - alma/composer.json - - alma/composer.lock - cmds: - - composer install --optimize-autoloader --working-dir=alma - lint:ci: desc: Run linter within docker-compose for the CI deps: @@ -53,7 +73,7 @@ tasks: lint: desc: Run linter deps: - - install-tools + - install:tools cmds: - php alma/vendor/bin/php-cs-fixer fix --dry-run --diff alma # Search for variables in smarty templates that are not escaped @@ -66,7 +86,7 @@ tasks: lint:fix: desc: Run linter and apply fix deps: - - install-tools + - install:tools cmds: - php alma/vendor/bin/php-cs-fixer fix alma # Execute autoindex to add index in all folders @@ -78,7 +98,7 @@ tasks: php-compatibility: desc: Check compatibility code deps: - - install-tools + - install:tools cmds: - php ./alma/vendor/bin/phpcs -p alma --standard=PHPCompatibility -s --runtime-set testVersion 5.6-8.1 --ignore=\*/vendor/\* From 16bc54e66989c13a214ca4d723d7dc95d3116dd5 Mon Sep 17 00:00:00 2001 From: Carine Bonnafous Date: Fri, 21 Jun 2024 14:55:48 +0200 Subject: [PATCH 05/10] chore(Taskfile): review: change task prefix --- Taskfile.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index aa033bf6..5f645a4f 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -24,13 +24,13 @@ tasks: cmds: - brew install pre-commit - install:pre-commit: + pre-commit:install: desc: Install and set up pre-commit hooks deps: [pre-commit] cmds: - pre-commit install --hook-type pre-commit --hook-type commit-msg - install:tools: + tools:install: desc: Composer install of tools sources: - alma/composer.json @@ -73,7 +73,7 @@ tasks: lint: desc: Run linter deps: - - install:tools + - tools:install cmds: - php alma/vendor/bin/php-cs-fixer fix --dry-run --diff alma # Search for variables in smarty templates that are not escaped @@ -86,7 +86,7 @@ tasks: lint:fix: desc: Run linter and apply fix deps: - - install:tools + - tools:install cmds: - php alma/vendor/bin/php-cs-fixer fix alma # Execute autoindex to add index in all folders @@ -98,7 +98,7 @@ tasks: php-compatibility: desc: Check compatibility code deps: - - install:tools + - tools:install cmds: - php ./alma/vendor/bin/phpcs -p alma --standard=PHPCompatibility -s --runtime-set testVersion 5.6-8.1 --ignore=\*/vendor/\* From 9de5b0f69e9d0ad2c571886437f74ecd4e966e7e Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Mon, 15 Jul 2024 11:18:36 +0200 Subject: [PATCH 06/10] fix: Issue PS Account with PS 8.1.7 --- alma/config/admin/services.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/alma/config/admin/services.yml b/alma/config/admin/services.yml index ae837ec7..934cf7b4 100644 --- a/alma/config/admin/services.yml +++ b/alma/config/admin/services.yml @@ -1,4 +1,6 @@ services: + _defaults: + public: true ##################### # PS Account @@ -10,4 +12,4 @@ services: alma.ps_accounts_facade: class: 'PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts' arguments: - - '@alma.ps_accounts_installer' \ No newline at end of file + - '@alma.ps_accounts_installer' From 19becf1c238ca77a002eb5c9edfc41e9492b8862 Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Mon, 15 Jul 2024 15:19:50 +0200 Subject: [PATCH 07/10] fix: Issue quantity insurance if we change quantity in cart --- alma/views/js/alma-cart-insurance.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/alma/views/js/alma-cart-insurance.js b/alma/views/js/alma-cart-insurance.js index 18f1ca38..cbd67f22 100644 --- a/alma/views/js/alma-cart-insurance.js +++ b/alma/views/js/alma-cart-insurance.js @@ -28,6 +28,9 @@ if (window.prestashop != null && window.prestashop.on != null) { prestashop.on("updatedCart", onloadInsuranceItemCartAlma); } + window.addEventListener('message', (e) => { + handleAddInsuranceProductFromWidget(e); + }); }); })(jQuery); @@ -182,10 +185,6 @@ function onloadInsuranceClickEvents() { }); }); - - window.addEventListener('message', (e) => { - handleAddInsuranceProductFromWidget(e); - }); } function handleAddInsuranceProductFromWidget(e) { From 30da8f71b40593af738eb5fba628a4a207defabe Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Mon, 15 Jul 2024 16:04:26 +0200 Subject: [PATCH 08/10] fix: Issue insurance for product not eligible created after import --- alma/views/js/alma-cart-insurance.js | 2 +- alma/views/js/alma-product-insurance.js | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/alma/views/js/alma-cart-insurance.js b/alma/views/js/alma-cart-insurance.js index 18f1ca38..8e125cad 100644 --- a/alma/views/js/alma-cart-insurance.js +++ b/alma/views/js/alma-cart-insurance.js @@ -218,7 +218,7 @@ function handleAddInsuranceProductFromWidget(e) { } } if (e.data.type === 'almaEligibilityAnswer') { - if (e.data.eligibilityCallResult.length > 0) { + if (e.data.eligibilityCallResponseStatus.response.eligibleProduct && e.data.eligibilityCallResult.length > 0) { $('#' + e.data.iFrameIdForProductWidget).show(); } } diff --git a/alma/views/js/alma-product-insurance.js b/alma/views/js/alma-product-insurance.js index 698fbc51..6601eea0 100644 --- a/alma/views/js/alma-product-insurance.js +++ b/alma/views/js/alma-product-insurance.js @@ -26,6 +26,7 @@ let selectedAlmaInsurance = null; let addToCartFlow = false; let productDetails = null; let quantity = 1; +let almaEligibilityAnswer = false; (function ($) { $(function () { @@ -97,8 +98,9 @@ function onloadAddInsuranceInputOnProductAlma() { window.addEventListener('message', (e) => { if (e.data.type === 'almaEligibilityAnswer') { + almaEligibilityAnswer = e.data.eligibilityCallResponseStatus.response.eligibleProduct; btnLoaders('stop'); - if (e.data.eligibilityCallResponseStatus.response.eligibleProduct === true) { + if (almaEligibilityAnswer) { let heightIframe = e.data.widgetSize.height; let stringHeightIframe = heightIframe + 'px'; if (heightIframe <= 45) { @@ -108,7 +110,7 @@ function onloadAddInsuranceInputOnProductAlma() { document.getElementById('alma-widget-insurance-product-page').style.height = stringHeightIframe; } else { let addToCart = document.querySelector('.add-to-cart'); - addToCart.removeEventListener("click",insuranceListener) + addToCart.removeEventListener("click", insuranceListener) } } if (e.data.type === 'getSelectedInsuranceData') { @@ -204,8 +206,9 @@ function removeInputInsurance() { } function addModalListenerToAddToCart() { - if (settings.isAddToCartPopupActivated === true) { + if (settings.isAddToCartPopupActivated === true && almaEligibilityAnswer) { let addToCart = document.querySelector('.add-to-cart'); + // If we change the quantity the DOM is reloaded then we need to remove and add the listener again addToCart.removeEventListener("click",insuranceListener) addToCart.addEventListener("click", insuranceListener); } From 65a4e577106556f303c4c7f74b849d1bd5312bb0 Mon Sep 17 00:00:00 2001 From: Benjamin Freoua Date: Tue, 16 Jul 2024 16:29:25 +0200 Subject: [PATCH 09/10] fix: Avoid change quantity with module pscartdropdown for insurance --- .../hook/FrontHeaderHookController.php | 10 ++++++--- alma/views/js/alma-insurance.js | 22 +++++++++++++++++++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/alma/controllers/hook/FrontHeaderHookController.php b/alma/controllers/hook/FrontHeaderHookController.php index 86503bf2..4bfb857f 100644 --- a/alma/controllers/hook/FrontHeaderHookController.php +++ b/alma/controllers/hook/FrontHeaderHookController.php @@ -326,6 +326,8 @@ protected function manageAssetVersionForPrestashopBefore17() */ public function manageInsuranceAssetsAfter17() { + $scripts = ''; + if ( $this->insuranceHelper->isInsuranceAllowedInProductPage() && $this->iAmInProductPage() @@ -337,7 +339,7 @@ public function manageInsuranceAssetsAfter17() "modules/$this->moduleName/" . ConstantsHelper::INSURANCE_PRODUCT_CSS_PATH ); - return $this->urlScriptInsuranceModal(); + $scripts .= $this->urlScriptInsuranceModal(); } if ( @@ -352,7 +354,7 @@ public function manageInsuranceAssetsAfter17() ); if ($this->insuranceHelper->isInsuranceAllowedInCartPage()) { - return $this->urlScriptInsuranceModal(); + $scripts .= $this->urlScriptInsuranceModal(); } } @@ -365,7 +367,9 @@ public function manageInsuranceAssetsAfter17() $this->controller->addJS($this->module->_path . ConstantsHelper::INSURANCE_SCRIPT_PATH); - return $this->almaInsuranceIdInHeader(); + $scripts .= $this->almaInsuranceIdInHeader(); + + return $scripts; } /** diff --git a/alma/views/js/alma-insurance.js b/alma/views/js/alma-insurance.js index b6a2a288..718c80e0 100644 --- a/alma/views/js/alma-insurance.js +++ b/alma/views/js/alma-insurance.js @@ -1,3 +1,25 @@ +/** + * 2018-2024 Alma SAS + * + * THE MIT LICENSE + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE + * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + * @author Alma SAS + * @copyright 2018-2024 Alma SAS + * @license https://opensource.org/licenses/MIT The MIT License + */ (function ($) { $(function () { loadInsuranceMiniCart(); From ed1b683e0f6bbc8a66a3915667ca11d8ec59f985 Mon Sep 17 00:00:00 2001 From: Benjamin-Freoua-Alma <89775252+Benjamin-Freoua-Alma@users.noreply.github.com> Date: Tue, 16 Jul 2024 15:17:34 +0000 Subject: [PATCH 10/10] chore: update version --- CHANGELOG.md | 15 +++++++++++++++ alma/alma.php | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a270098b..50b6904a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Changelog +## v4.1.2 - 2024-07-16 + +### Changes + +### 🐛 Bug Fixes + +- fix: Avoid change quantity with module pscartdropdown for insurance (#510) +- fix: Issue PS Account with PS 8.1.7 (#506) +- fix: Issue quantity insurance if we change quantity in cart (#508) +- fix: Issue insurance for product not eligible created after import (#509) + +#### Contributors + +@Benjamin-Freoua-Alma, @carine-bonnafous and @github-actions + ## v4.1.1 - 2024-07-10 ### Changes diff --git a/alma/alma.php b/alma/alma.php index d99bfa66..2a5a1eea 100644 --- a/alma/alma.php +++ b/alma/alma.php @@ -33,7 +33,7 @@ class Alma extends PaymentModule { - const VERSION = '4.1.1'; + const VERSION = '4.1.2'; public $_path; public $local_path; @@ -83,7 +83,7 @@ public function __construct() { $this->name = 'alma'; $this->tab = 'payments_gateways'; - $this->version = '4.1.1'; + $this->version = '4.1.2'; $this->author = 'Alma'; $this->need_instance = false; $this->bootstrap = true;