Skip to content

Commit c301721

Browse files
Added support for float button to handle user preferences
1 parent b63ad39 commit c301721

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

cookieconsent.php

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ class CookieConsent extends Module
4343
const CC_THEME = 'CC_THEME';
4444
const CC_GTM_CONSENT_MODE = 'CC_GTM_CONSENT_MODE';
4545
const CC_FB_CONSENT_MODE = 'CC_FB_CONSENT_MODE';
46+
const CC_ENABLE_FLOAT_PREFERENCES = 'CC_ENABLE_FLOAT_PREFERENCES';
4647

4748
public function __construct()
4849
{
4950
$this->name = 'cookieconsent';
5051
$this->tab = 'front_office_features';
51-
$this->version = '1.0.2';
52+
$this->version = '1.0.3';
5253
$this->author = 'Novanta';
5354
$this->displayName = ('Cookie Consent');
5455
$this->description = ('This module install cookie consent to manage user preferences with GTM Consent Mode compatibility');
@@ -78,6 +79,7 @@ public function install()
7879
Configuration::updateValue(self::CC_THEME, 'light');
7980
Configuration::updateValue(self::CC_GTM_CONSENT_MODE, false);
8081
Configuration::updateValue(self::CC_FB_CONSENT_MODE, false);
82+
Configuration::updateValue(self::CC_ENABLE_FLOAT_PREFERENCES, true);
8183

8284
return parent::install() &&
8385
$this->registerHook('displayHeader') &&
@@ -383,6 +385,25 @@ protected function getConfigForm()
383385
)
384386
),
385387
),
388+
array(
389+
'type' => 'switch',
390+
'label' => $this->trans('Enable float preferences button', [], 'Modules.Cookieconsent.Admin'),
391+
'name' => self::CC_ENABLE_FLOAT_PREFERENCES,
392+
'is_bool' => true,
393+
'desc' => $this->trans('Enable float preferences button to handle user preferences', [], 'Modules.Cookieconsent.Admin'),
394+
'values' => array(
395+
array(
396+
'id' => 'active_on',
397+
'value' => true,
398+
'label' => $this->trans('Enabled', [], 'Modules.Cookieconsent.Admin')
399+
),
400+
array(
401+
'id' => 'active_off',
402+
'value' => false,
403+
'label' => $this->trans('Disabled', [], 'Modules.Cookieconsent.Admin')
404+
)
405+
),
406+
),
386407
array(
387408
'type' => 'select',
388409
'label' => $this->trans('Theme', [], 'Modules.Cookieconsent.Admin'),
@@ -466,7 +487,8 @@ protected function getConfigFormValues()
466487
self::CC_DISPLAY_SECTION_SECURITY => Configuration::get(self::CC_DISPLAY_SECTION_SECURITY, null, null, null, true),
467488
self::CC_THEME => Configuration::get(self::CC_THEME, null, null, null, true),
468489
self::CC_GTM_CONSENT_MODE => Configuration::get(self::CC_GTM_CONSENT_MODE, null, null, null, false),
469-
self::CC_FB_CONSENT_MODE => Configuration::get(self::CC_FB_CONSENT_MODE, null, null, null, false)
490+
self::CC_FB_CONSENT_MODE => Configuration::get(self::CC_FB_CONSENT_MODE, null, null, null, false),
491+
self::CC_ENABLE_FLOAT_PREFERENCES => Configuration::get(self::CC_ENABLE_FLOAT_PREFERENCES, null, null, null, true),
470492
);
471493
}
472494

@@ -636,6 +658,8 @@ public function hookdisplayHeader()
636658
*/
637659
public function hookDisplayFooter()
638660
{
639-
return $this->display(__FILE__, "views/templates/front/hook/displayFooter.tpl");
661+
if(Configuration::get(self::CC_ENABLE_FLOAT_PREFERENCES)) {
662+
return $this->display(__FILE__, "views/templates/front/hook/displayFooter.tpl");
663+
}
640664
}
641665
}

upgrade/upgrade-1.0.3.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
if (!defined('_PS_VERSION_')) {
4+
exit;
5+
}
6+
7+
/**
8+
* Funzione che effettua l'upgrade del modulo
9+
*/
10+
function upgrade_module_1_0_3($module)
11+
{
12+
Configuration::updateValue($module::CC_ENABLE_FLOAT_PREFERENCES, true);
13+
14+
return true;
15+
}

0 commit comments

Comments
 (0)