diff --git a/Model/Config/PrivacyMessage.php b/Model/Config/PrivacyMessage.php
index e6240183..65cb1f8e 100644
--- a/Model/Config/PrivacyMessage.php
+++ b/Model/Config/PrivacyMessage.php
@@ -7,7 +7,7 @@
namespace Opengento\Gdpr\Model\Config;
-use Magento\Cms\Block\Block;
+use Magento\Cms\Block\BlockByIdentifier;
use Magento\Cms\Helper\Page as HelperPage;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\View\Element\BlockFactory;
@@ -15,21 +15,16 @@
final class PrivacyMessage
{
+ private const CONFIG_PATH_COOKIE_INFORMATION_ENABLED = 'gdpr/cookie/enabled';
private const CONFIG_PATH_COOKIE_INFORMATION_BLOCK = 'gdpr/cookie/block_id';
- private const CONFIG_PATH_GENERAL_INFORMATION_PAGE = 'gdpr/general/page_id';
+ private const CONFIG_PATH_COOKIE_INFORMATION_PAGE = 'gdpr/cookie/page_id';
private ScopeConfigInterface $scopeConfig;
private BlockFactory $blockFactory;
- /**
- * @var HelperPage
- */
private HelperPage $helperPage;
- /**
- * @var string|null
- */
private ?string $blockHtml;
public function __construct(
@@ -42,26 +37,31 @@ public function __construct(
$this->helperPage = $helperPage;
}
+ public function isEnabled(): bool
+ {
+ return $this->scopeConfig->isSetFlag(self::CONFIG_PATH_COOKIE_INFORMATION_ENABLED, ScopeInterface::SCOPE_STORE);
+ }
+
public function getDisclosureInformationHtml(): string
{
return $this->blockHtml ??= $this->createDisclosureInformationBlockHtml();
}
- public function getLearnMoreUrl(): string
+ public function getLearnMoreUrl(): ?string
{
return $this->helperPage->getPageUrl((string) $this->scopeConfig->getValue(
- self::CONFIG_PATH_GENERAL_INFORMATION_PAGE,
+ self::CONFIG_PATH_COOKIE_INFORMATION_PAGE,
ScopeInterface::SCOPE_STORE
- )) ?? '#';
+ ));
}
private function createDisclosureInformationBlockHtml(): string
{
return $this->blockFactory->createBlock(
- Block::class,
+ BlockByIdentifier::class,
[
'data' => [
- 'block_id' => (string) $this->scopeConfig->getValue(
+ 'identifier' => (string) $this->scopeConfig->getValue(
self::CONFIG_PATH_COOKIE_INFORMATION_BLOCK,
ScopeInterface::SCOPE_STORE
),
diff --git a/ViewModel/Cookie/NoticeDataProvider.php b/ViewModel/Cookie/NoticeDataProvider.php
new file mode 100644
index 00000000..5dfdb397
--- /dev/null
+++ b/ViewModel/Cookie/NoticeDataProvider.php
@@ -0,0 +1,36 @@
+privacyMessage = $privacyMessage;
+ }
+
+ public function getTemplate(string $defaultTemplate, string $customTemplate): string
+ {
+ return $this->privacyMessage->isEnabled() ? $customTemplate : $defaultTemplate;
+ }
+
+ public function getLearnMoreUrl(): ?string
+ {
+ return $this->privacyMessage->getLearnMoreUrl();
+ }
+
+ public function getNoticeHtml(): string
+ {
+ return $this->privacyMessage->getDisclosureInformationHtml();
+ }
+}
diff --git a/composer.json b/composer.json
index f80a448d..87113612 100755
--- a/composer.json
+++ b/composer.json
@@ -16,6 +16,7 @@
"magento/framework": "^103.0",
"magento/module-backend": "^101.0||^102.0",
"magento/module-config": "^101.1",
+ "magento/module-cookie": "^100.0",
"magento/module-customer": "^102.0||^103.0",
"magento/module-quote": "^101.1",
"magento/module-sales": "^102.0||^103.0",
diff --git a/etc/adminhtml/system/cookie.xml b/etc/adminhtml/system/cookie.xml
index 9f421777..0e2b4065 100644
--- a/etc/adminhtml/system/cookie.xml
+++ b/etc/adminhtml/system/cookie.xml
@@ -14,19 +14,27 @@
-
- It will enable the cookie disclosure popin to the storefront.
+
+ It will allows to replace the default cookie restriction popin with content of your own. Make sure that the following configuration is enabled: "General / Web / Default Cookie Settings / Cookie Restriction Mode".
Magento\Config\Model\Config\Source\Enabledisable
gdpr/cookie/enabled
-
+
Magento\Cms\Model\Config\Source\Block
1
gdpr/cookie/block_id
+
+
+ Magento\Cms\Model\Config\Source\Page
+
+ 1
+
+ gdpr/cookie/page_id
+
diff --git a/view/frontend/layout/default.xml b/view/frontend/layout/default.xml
index 011484dd..1ba1a722 100644
--- a/view/frontend/layout/default.xml
+++ b/view/frontend/layout/default.xml
@@ -7,25 +7,14 @@
-->
-
-
-
- Opengento_Gdpr::messages/popup.phtml
-
- -
-
-
-
- Opengento_Gdpr/js/view/popup
- - enhanced-privacy-cookie-policy
- -
-
- cookies-policy
-
-
-
-
-
-
-
-
-
+
+
+
+ Magento_Cookie::html/notices.phtml
+ Opengento_Gdpr::cookie/notices.phtml
+
+ Opengento\Gdpr\ViewModel\Cookie\NoticeDataProvider
+
+
diff --git a/view/frontend/templates/cookie/notices.phtml b/view/frontend/templates/cookie/notices.phtml
new file mode 100644
index 00000000..1149bd6d
--- /dev/null
+++ b/view/frontend/templates/cookie/notices.phtml
@@ -0,0 +1,59 @@
+getData('cookieHelper');
+/** @var NoticeDataProvider $noticeDataProvider */
+$noticeDataProvider = $block->getData('noticeDataProvider');
+
+$learnMoreUrl = $noticeDataProvider->getLearnMoreUrl() ?: $block->getPrivacyPolicyLink()
+?>
+isCookieRestrictionModeEnabled()): ?>
+
+
+
+ = /* @noEscape */ $noticeDataProvider->getNoticeHtml() ?>
+
+ = $block->escapeHtml(__('We use cookies to make your experience better.')) ?>
+ = $block->escapeHtml(__('Learn more.', $learnMoreUrl), ['a']) ?>
+
+
+
+
+
+
+
+ = /* @noEscape */ $secureRenderer->renderStyleAsTag('display: none;', 'div#notice-cookie-block') ?>
+
+
diff --git a/view/frontend/templates/messages/popup.phtml b/view/frontend/templates/messages/popup.phtml
deleted file mode 100644
index e3803a01..00000000
--- a/view/frontend/templates/messages/popup.phtml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
diff --git a/view/frontend/web/css/source/_module.less b/view/frontend/web/css/source/_module.less
index cdb9d475..009ed35d 100644
--- a/view/frontend/web/css/source/_module.less
+++ b/view/frontend/web/css/source/_module.less
@@ -23,37 +23,4 @@
}
}
}
-
- .enhanced-privacy-popup {
- position: fixed;
- right: 0;
- bottom: 0;
- left: 0;
- background: @color-gray-light01;
- overflow: hidden;
-
- .popup {
- &.content {
- margin: auto;
- padding: 10px 0;
- width: @screen__m;
- }
- }
- }
-}
-
-//
-// Mobile
-// _____________________________________________
-
-.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
- .enhanced-privacy-popup {
- .popup {
- &.content {
- margin: 0;
- padding: 10px;
- width: auto;
- }
- }
- }
}
diff --git a/view/frontend/web/js/view/popup.js b/view/frontend/web/js/view/popup.js
deleted file mode 100644
index 2a72fdc0..00000000
--- a/view/frontend/web/js/view/popup.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * This file is part of the Flurrybox EnhancedPrivacy package.
- *
- * DISCLAIMER
- *
- * Do not edit or add to this file if you wish to upgrade Flurrybox EnhancedPrivacy
- * to newer versions in the future.
- *
- * @copyright Copyright (c) 2018 Flurrybox, Ltd. (https://flurrybox.com/)
- * @license GNU General Public License ("GPL") v3.0
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
-define([
- "jquery",
- "uiComponent",
- "ko",
- "mage/cookies"
-], function ($, Component, ko) {
- "use strict";
-
- return Component.extend({
- showPopUp: ko.observable(false),
-
- defaults: {
- template: "Opengento_Gdpr/message"
- },
-
- /**
- * Initialize component
- */
- initialize() {
- var self = this,
- isBot = navigator.userAgent.toLowerCase().match( /.+?(?:bot|lighthouse)/ );
-
- this._super();
-
- if (!window.localStorage.getItem(self.cookieName) && !isBot) {
- self.showPopUp(true);
- }
- },
-
- /**
- * Get Popup Text
- * @returns {string}
- */
- getPopupText() {
- var self = this;
-
- return self.notificationText;
- },
-
- /**
- * Get Popup Link
- * @returns {string}
- */
- getPopupLink() {
- var self = this;
-
- return self.learnMore;
- },
-
- /**
- * Accept All Cookies
- * @returns {void}
- */
- acceptAllCookies() {
- var self = this;
-
- window.localStorage.setItem(self.cookieName, true, {});
- self.showPopUp(false);
- }
- });
-});
diff --git a/view/frontend/web/template/message.html b/view/frontend/web/template/message.html
deleted file mode 100644
index 06ca70df..00000000
--- a/view/frontend/web/template/message.html
+++ /dev/null
@@ -1,32 +0,0 @@
-
-