Skip to content

Commit

Permalink
Merge pull request #555 from alma/release/v4.2.0
Browse files Browse the repository at this point in the history
Release v4.2.0
  • Loading branch information
Benjamin-Freoua-Alma authored Aug 6, 2024
2 parents 99e1bfb + 08b87db commit 6a5d729
Show file tree
Hide file tree
Showing 66 changed files with 2,029 additions and 507 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Build docker images
uses: docker/bake-action@v4
uses: docker/bake-action@v5
with:
files: compose.yml
pull: true
Expand All @@ -48,3 +48,9 @@ jobs:
run: task test
env:
XDEBUG_MODE: coverage

- name: Install semgrep
run: pip install semgrep

- name: Run semgrep
run: semgrep scan --config semgrep/rules
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/commitizen-tools/commitizen
rev: v3.27.0
rev: v3.28.0
hooks:
- id: commitizen
name: Check commit message format
Expand Down Expand Up @@ -39,7 +39,7 @@ repos:
stages: [commit]

- repo: https://github.com/returntocorp/semgrep
rev: v1.78.0
rev: v1.81.0
hooks:
- id: semgrep
args:
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Changelog

## v4.2.0 - 2024-08-06

### Changes

### 🚀 New Features

- feat: Insurance compatability with PS 1.7 (#522)
- feat: Insurance product page cannot be added to cart (#530)

### 🐛 Bug Fixes

- fix: create payment with object category in product (#551)
- fix: load alma script on dashboard for ps17 (#549)
- fix: eligible limit of feePlans (#550)
- fix: display multiple notification dashboard on ps17 (#548)
- fix: install module with ps_account from ps17 to ps8 (#547)
- fix: openmodal insurance in the first load product page (#543)
- fix: change order status error (#542)
- fix: install module without ConfigCache about PS Account (#541)

#### Contributors

@Benjamin-Freoua-Alma, @alma-renovate-bot, @alma-renovate-bot[bot], @carine-bonnafous and @github-actions

## v4.1.4 - 2024-07-29

### Changes
Expand Down
53 changes: 48 additions & 5 deletions alma/alma.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class Alma extends PaymentModule
{
const VERSION = '4.1.4';
const VERSION = '4.2.0';

public $_path;
public $local_path;
Expand Down Expand Up @@ -80,7 +80,7 @@ public function __construct()
{
$this->name = 'alma';
$this->tab = 'payments_gateways';
$this->version = '4.1.4';
$this->version = '4.2.0';
$this->author = 'Alma';
$this->need_instance = false;
$this->bootstrap = true;
Expand Down Expand Up @@ -150,6 +150,7 @@ public function checkCompatibilityPSModule()
{
if (
$this->toolsHelper->psVersionCompare('1.6', '<')
|| !class_exists(\Symfony\Component\Config\ConfigCache::class)
|| !class_exists(\PrestaShop\ModuleLibServiceContainer\DependencyInjection\ServiceContainer::class)
|| _PS_MODE_DEV_ === true
) {
Expand Down Expand Up @@ -419,7 +420,19 @@ public function hookTermsAndConditions($params)
}

/**
* Hook to modify the order table
* Hook to modify the order table before Ps 1.7.5
*
* @param $params
*
* @return mixed|null
*/
public function hookActionAdminOrdersListingFieldsModifier($params)
{
return $this->runHookController('actionAdminOrdersListingFieldsModifier', $params);
}

/**
* Hook to modify the order table after Ps 1.7.5
*
* @param $params
*
Expand All @@ -431,7 +444,7 @@ public function hookActionOrderGridQueryBuilderModifier($params)
}

/**
* Hook to modify the order table
* Hook to modify the order table after Ps 1.7.5
*
* @param $params
*
Expand Down Expand Up @@ -649,11 +662,21 @@ public function hookDisplayPayment($params)
return $this->runHookController('displayPayment', $params);
}

public function hookDeleteProductInCartAfter($params)
/**
* @param $params
*
* @return mixed|null
*/
public function hookActionAfterDeleteProductInCart($params)
{
return $this->hookActionObjectProductInCartDeleteAfter($params);
}

/**
* @param $params
*
* @return mixed|null
*/
public function hookActionObjectProductInCartDeleteAfter($params)
{
return $this->runHookController('actionObjectProductInCartDeleteAfter', $params);
Expand Down Expand Up @@ -711,4 +734,24 @@ public function hookDisplayAdminAfterHeader($params)
{
return $this->runHookController('displayAdminAfterHeader', $params);
}

/**
* @param $params
*
* @return mixed|null
*/
public function hookActionFrontControllerSetVariables($params)
{
return $this->runHookController('actionFrontControllerSetVariables', $params);
}

/**
* @param $params
*
* @return mixed|null
*/
public function hookActionGetProductPropertiesBefore($params)
{
return $this->runHookController('actionGetProductPropertiesBefore', $params);
}
}
5 changes: 2 additions & 3 deletions alma/config/admin/services.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
services:
_defaults:
public: true

#####################
# PS Account
alma.ps_accounts_installer:
public: true
class: 'PrestaShop\PsAccountsInstaller\Installer\Installer'
arguments:
- '5.0'

alma.ps_accounts_facade:
public: true
class: 'PrestaShop\PsAccountsInstaller\Installer\Facade\PsAccounts'
arguments:
- '@alma.ps_accounts_installer'
3 changes: 0 additions & 3 deletions alma/controllers/front/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* @license https://opensource.org/licenses/MIT The MIT License
*/

use Alma\API\ParamsError;
use Alma\PrestaShop\Builders\Helpers\SettingsHelperBuilder;
use Alma\PrestaShop\Builders\Models\PaymentDataBuilder;
use Alma\PrestaShop\Helpers\ClientHelper;
Expand Down Expand Up @@ -106,9 +105,7 @@ private function ajaxErrorAndDie()
/**
* @return void
*
* @throws PrestaShopDatabaseException
* @throws PrestaShopException
* @throws ParamsError
*/
public function postProcess()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?php
/**
* 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 <[email protected]>
* @copyright 2018-2024 Alma SAS
* @license https://opensource.org/licenses/MIT The MIT License
*/

namespace Alma\PrestaShop\Controllers\Hook;

use Alma\PrestaShop\Builders\Helpers\InsuranceHelperBuilder;
use Alma\PrestaShop\Helpers\InsuranceHelper;
use Alma\PrestaShop\Helpers\SettingsHelper;
use Alma\PrestaShop\Hooks\AdminHookController;

class ActionAdminOrdersListingFieldsModifierHookController extends AdminHookController
{
/**
* @var InsuranceHelper
*/
protected $insuranceHelper;

public function canRun()
{
// Front controllers can run if the module is properly configured ...
return SettingsHelper::isFullyConfigured()
// ... and the plugin is in LIVE mode, or the visitor is an admin
&& $this->insuranceHelper->isInsuranceActivated();
}

/**
* @param $module
*/
public function __construct($module)
{
parent::__construct($module);

$insuranceHelperBuilder = new InsuranceHelperBuilder();
$this->insuranceHelper = $insuranceHelperBuilder->getInstance();
}

/**
* Run Controller
*
* @param array $params
*
* @return void
*/
public function run($params)
{
if (array_key_exists('select', $params)) {
$params['select'] .= ' ,IF(aip.`id_order` IS NOT NULL,1,0) as has_alma_insurance ';
}
if (array_key_exists('join', $params)) {
$params['join'] .= 'LEFT JOIN ' . _DB_PREFIX_ . 'alma_insurance_product aip ON (a.id_order = aip.id_order)';
}
if (array_key_exists('group_by', $params)) {
$params['group_by'] .= 'GROUP BY a.id_order';
}
$params['fields']['has_alma_insurance'] = [
'title' => 'Has Insurance',
'type' => 'bool',
'tmpTableFilter' => true,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* 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 <[email protected]>
* @copyright 2018-2024 Alma SAS
* @license https://opensource.org/licenses/MIT The MIT License
*/

namespace Alma\PrestaShop\Controllers\Hook;

use Alma\PrestaShop\Helpers\ConstantsHelper;
use Alma\PrestaShop\Hooks\FrontendHookController;
use Alma\PrestaShop\Repositories\ProductRepository;

if (!defined('_PS_VERSION_')) {
exit;
}

class ActionFrontControllerSetVariablesHookController extends FrontendHookController
{
protected $productRepository;

public function __construct($module, $productRepository = null)
{
parent::__construct($module);

if (is_null($productRepository)) {
$productRepository = new ProductRepository();
}

$this->productRepository = $productRepository;
}

/**
* @param $params
*
* @return bool
*/
public function run($params)
{
if ($this->checkIsInsuranceProduct($params)) {
return $params['templateVars']['configuration']['is_catalog'] = true;
}

return false;
}

/**
* @param $params
*
* @return bool
*/
private function checkIsInsuranceProduct($params)
{
$templateVars = $params['templateVars'];
$idInsuranceProduct = $this->productRepository->getProductIdByReference(ConstantsHelper::ALMA_INSURANCE_PRODUCT_REFERENCE);

if (
is_null($idInsuranceProduct) ||
!array_key_exists('page', $templateVars) ||
$templateVars['page']['page_name'] !== 'product' ||
!array_key_exists('product-id-' . $idInsuranceProduct, $templateVars['page']['body_classes'])
) {
return false;
}

return true;
}
}
Loading

0 comments on commit 6a5d729

Please sign in to comment.