Skip to content

Commit

Permalink
Added support for float button to handle user preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
LorenzoMinciotti committed Jun 16, 2023
1 parent b63ad39 commit c301721
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
30 changes: 27 additions & 3 deletions cookieconsent.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,13 @@ class CookieConsent extends Module
const CC_THEME = 'CC_THEME';
const CC_GTM_CONSENT_MODE = 'CC_GTM_CONSENT_MODE';
const CC_FB_CONSENT_MODE = 'CC_FB_CONSENT_MODE';
const CC_ENABLE_FLOAT_PREFERENCES = 'CC_ENABLE_FLOAT_PREFERENCES';

public function __construct()
{
$this->name = 'cookieconsent';
$this->tab = 'front_office_features';
$this->version = '1.0.2';
$this->version = '1.0.3';
$this->author = 'Novanta';
$this->displayName = ('Cookie Consent');
$this->description = ('This module install cookie consent to manage user preferences with GTM Consent Mode compatibility');
Expand Down Expand Up @@ -78,6 +79,7 @@ public function install()
Configuration::updateValue(self::CC_THEME, 'light');
Configuration::updateValue(self::CC_GTM_CONSENT_MODE, false);
Configuration::updateValue(self::CC_FB_CONSENT_MODE, false);
Configuration::updateValue(self::CC_ENABLE_FLOAT_PREFERENCES, true);

return parent::install() &&
$this->registerHook('displayHeader') &&
Expand Down Expand Up @@ -383,6 +385,25 @@ protected function getConfigForm()
)
),
),
array(
'type' => 'switch',
'label' => $this->trans('Enable float preferences button', [], 'Modules.Cookieconsent.Admin'),
'name' => self::CC_ENABLE_FLOAT_PREFERENCES,
'is_bool' => true,
'desc' => $this->trans('Enable float preferences button to handle user preferences', [], 'Modules.Cookieconsent.Admin'),
'values' => array(
array(
'id' => 'active_on',
'value' => true,
'label' => $this->trans('Enabled', [], 'Modules.Cookieconsent.Admin')
),
array(
'id' => 'active_off',
'value' => false,
'label' => $this->trans('Disabled', [], 'Modules.Cookieconsent.Admin')
)
),
),
array(
'type' => 'select',
'label' => $this->trans('Theme', [], 'Modules.Cookieconsent.Admin'),
Expand Down Expand Up @@ -466,7 +487,8 @@ protected function getConfigFormValues()
self::CC_DISPLAY_SECTION_SECURITY => Configuration::get(self::CC_DISPLAY_SECTION_SECURITY, null, null, null, true),
self::CC_THEME => Configuration::get(self::CC_THEME, null, null, null, true),
self::CC_GTM_CONSENT_MODE => Configuration::get(self::CC_GTM_CONSENT_MODE, null, null, null, false),
self::CC_FB_CONSENT_MODE => Configuration::get(self::CC_FB_CONSENT_MODE, null, null, null, false)
self::CC_FB_CONSENT_MODE => Configuration::get(self::CC_FB_CONSENT_MODE, null, null, null, false),
self::CC_ENABLE_FLOAT_PREFERENCES => Configuration::get(self::CC_ENABLE_FLOAT_PREFERENCES, null, null, null, true),
);
}

Expand Down Expand Up @@ -636,6 +658,8 @@ public function hookdisplayHeader()
*/
public function hookDisplayFooter()
{
return $this->display(__FILE__, "views/templates/front/hook/displayFooter.tpl");
if(Configuration::get(self::CC_ENABLE_FLOAT_PREFERENCES)) {
return $this->display(__FILE__, "views/templates/front/hook/displayFooter.tpl");
}
}
}
15 changes: 15 additions & 0 deletions upgrade/upgrade-1.0.3.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

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

/**
* Funzione che effettua l'upgrade del modulo
*/
function upgrade_module_1_0_3($module)
{
Configuration::updateValue($module::CC_ENABLE_FLOAT_PREFERENCES, true);

return true;
}

0 comments on commit c301721

Please sign in to comment.