Skip to content

Commit

Permalink
Merge branch 'develop' into feature/ECOM-1170/backoffice-almapagecss-…
Browse files Browse the repository at this point in the history
…breaks-switchs-in-prestashop-81
  • Loading branch information
Benjamin-Freoua-Alma authored Jan 11, 2024
2 parents 3df0c43 + 4fdc3ba commit c9edb06
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 40 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## v3.1.3

- feat: Remove merchant tag for in-page on Prestashop
- fix: CSS of Prestashop Switch button on Back-office setting

## v3.1.2
Expand Down
6 changes: 2 additions & 4 deletions alma/controllers/hook/GetContentHookController.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,10 +590,8 @@ protected function buildForms($needsKeys, $feePlansOrdered, $installmentsPlans)
$fieldsForms[] = $shareOfCheckoutBuilder->build();
}

if (SettingsHelper::isInpageAllowed()) {
$inpageBuilder = new InpageAdminFormBuilder($this->module, $this->context, $iconPath);
$fieldsForms[] = $inpageBuilder->build();
}
$inpageBuilder = new InpageAdminFormBuilder($this->module, $this->context, $iconPath);
$fieldsForms[] = $inpageBuilder->build();
}

if (SettingsHelper::isPaymentTriggerEnabledByState()) {
Expand Down
25 changes: 0 additions & 25 deletions alma/lib/Helpers/ApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,31 +70,6 @@ public static function getMerchant($module, $alma = null)
throw new ActivationException($module);
}

static::saveFeatureFlag($merchant, 'cms_allow_inpage', ConstantsHelper::ALMA_ALLOW_INPAGE);

return $merchant;
}

/**
* @param \Alma\API\Entities\Merchant $merchant
* @param string $merchantKey
* @param string $configKey
*
* @return void
*/
protected static function saveFeatureFlag($merchant, $merchantKey, $configKey)
{
$value = 1;

if (property_exists($merchant, $merchantKey)) {
$value = $merchant->$merchantKey;
}

SettingsHelper::updateValue($configKey, (int) $value);

// If Inpage not allowed we ensure that inpage is deactivated in database
if (0 === $value) {
SettingsHelper::updateValue(InpageAdminFormBuilder::ALMA_ACTIVATE_INPAGE, (int) $value);
}
}
}
2 changes: 0 additions & 2 deletions alma/lib/Helpers/ConstantsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,4 @@ class ConstantsHelper
const SOURCE_CUSTOM_FIELDS = 'CustomFieldsHelper';

const ALMA_KEY_PAYNOW = 'general_1_0_0';

const ALMA_ALLOW_INPAGE = 'ALMA_ALLOW_INPAGE';
}
9 changes: 0 additions & 9 deletions alma/lib/Helpers/SettingsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ public static function deleteAllValues()
'ALMA_CART_WDGT_NOT_ELGBL',
'ALMA_PRODUCT_WDGT_NOT_ELGBL',
'ALMA_CATEGORIES_WDGT_NOT_ELGBL',
ConstantsHelper::ALMA_ALLOW_INPAGE,
];

foreach ($configKeys as $configKey) {
Expand Down Expand Up @@ -271,14 +270,6 @@ public static function getCurrentTimestamp()
return $date->getTimestamp();
}

/**
* @return bool
*/
public static function isInpageAllowed()
{
return (bool) static::get(ConstantsHelper::ALMA_ALLOW_INPAGE, 0);
}

/**
* Get API mode saved in Prestashop database.
*
Expand Down
50 changes: 50 additions & 0 deletions alma/upgrade/upgrade-3.1.3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php
/**
* 2018-2023 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-2023 Alma SAS
* @license https://opensource.org/licenses/MIT The MIT License
*/
if (!defined('_PS_VERSION_')) {
exit;
}

use Alma\PrestaShop\Helpers\ClientHelper;
use Alma\PrestaShop\Helpers\SettingsHelper;

function upgrade_module_3_1_3()
{
if (SettingsHelper::isFullyConfigured()) {
$alma = ClientHelper::defaultInstance();

if (!$alma) {
return true;
}

$deleteKeys = [
'ALMA_ALLOW_INPAGE',
];

foreach ($deleteKeys as $deleteKey) {
Configuration::deleteByName($deleteKey);
}
}

return true;
}

0 comments on commit c9edb06

Please sign in to comment.