Improved GDPR compliance
- Add more customization TODO: Update styling
This commit is contained in:
@ -224,4 +224,73 @@
|
||||
.gdpr-cookie-more-info {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.gdpr-cookie-info-block {
|
||||
margin: 15px 0;
|
||||
padding: 15px;
|
||||
background-color: #f9f9f9;
|
||||
border: 1px solid #eee;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-info-block p {
|
||||
margin: 5px 0;
|
||||
font-size: 13px;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.gdpr-cookie-banner-info {
|
||||
margin: 5px 0 10px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-banner-info p {
|
||||
font-size: 12px;
|
||||
opacity: 0.9;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Equal prominence for buttons */
|
||||
.gdpr-cookie-banner-decline,
|
||||
.gdpr-cookie-banner-accept {
|
||||
font-weight: 400;
|
||||
padding: 8px 15px;
|
||||
border-radius: 3px;
|
||||
/* Make both buttons similar size but distinctive */
|
||||
min-width: 120px;
|
||||
}
|
||||
|
||||
.gdpr-cookie-banner-decline {
|
||||
background-color: #f1f1f1;
|
||||
color: #333;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.gdpr-cookie-banner-accept {
|
||||
background-color: #4caf50;
|
||||
color: white;
|
||||
border: 1px solid #4caf50;
|
||||
}
|
||||
|
||||
/* Manage button styles */
|
||||
.gdpr-cookie-manage-button {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
z-index: 9990;
|
||||
}
|
||||
|
||||
.gdpr-cookie-manage {
|
||||
padding: 8px 12px;
|
||||
background-color: #f1f1f1;
|
||||
color: #333;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 3px;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.gdpr-cookie-manage:hover {
|
||||
background-color: #e5e5e5;
|
||||
}
|
@ -29,6 +29,21 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Show manage preferences button when cookies are already set
|
||||
function showManageButton() {
|
||||
document.getElementById('gdpr-cookie-manage-button').style.display = 'block';
|
||||
}
|
||||
|
||||
// After user consents, hide banner and modal and show the manage button
|
||||
function afterConsent() {
|
||||
// Hide banner and modal
|
||||
hideModal();
|
||||
document.getElementById('gdpr-cookie-banner').style.display = 'none';
|
||||
|
||||
// Show manage button
|
||||
showManageButton();
|
||||
}
|
||||
|
||||
// Check if cookie consent is already set
|
||||
var cookieConsent = getCookie('gdpr_cookie_consent');
|
||||
|
||||
@ -39,6 +54,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
// Apply cookie preferences
|
||||
var consentPreferences = JSON.parse(cookieConsent);
|
||||
applyConsentPreferences(consentPreferences);
|
||||
|
||||
// Show the manage button since consent was already given
|
||||
showManageButton();
|
||||
}
|
||||
|
||||
// Banner buttons
|
||||
@ -67,6 +85,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
acceptSelectedCookies();
|
||||
});
|
||||
|
||||
// Manage button (for after consent is given)
|
||||
document.getElementById('gdpr-cookie-manage').addEventListener('click', function() {
|
||||
showModal();
|
||||
});
|
||||
|
||||
// Functions
|
||||
function showModal() {
|
||||
document.getElementById('gdpr-cookie-banner').style.display = 'none';
|
||||
@ -103,8 +126,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
setCookie('gdpr_cookie_consent', JSON.stringify(preferences), 365);
|
||||
applyConsentPreferences(preferences);
|
||||
hideModal();
|
||||
document.getElementById('gdpr-cookie-banner').style.display = 'none';
|
||||
afterConsent(); // Use the new function for consistent post-consent behavior
|
||||
}
|
||||
|
||||
function declineAllCookies() {
|
||||
@ -117,8 +139,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
setCookie('gdpr_cookie_consent', JSON.stringify(preferences), 365);
|
||||
applyConsentPreferences(preferences);
|
||||
hideModal();
|
||||
document.getElementById('gdpr-cookie-banner').style.display = 'none';
|
||||
afterConsent(); // Use the new function for consistent post-consent behavior
|
||||
}
|
||||
|
||||
function acceptSelectedCookies() {
|
||||
@ -134,8 +155,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
setCookie('gdpr_cookie_consent', JSON.stringify(preferences), 365);
|
||||
applyConsentPreferences(preferences);
|
||||
hideModal();
|
||||
document.getElementById('gdpr-cookie-banner').style.display = 'none';
|
||||
afterConsent(); // Use the new function for consistent post-consent behavior
|
||||
}
|
||||
|
||||
function applyConsentPreferences(preferences) {
|
||||
@ -179,6 +199,11 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
function disableAnalytics() {
|
||||
// Example: Disable Google Analytics
|
||||
window['ga-disable-UA-XXXXXXXX-X'] = true;
|
||||
|
||||
// Remove existing GA cookies
|
||||
document.cookie = '_ga=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT; Domain=.' + window.location.hostname;
|
||||
document.cookie = '_gid=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT; Domain=.' + window.location.hostname;
|
||||
document.cookie = '_gat=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT; Domain=.' + window.location.hostname;
|
||||
}
|
||||
|
||||
function enableAnalytics() {
|
||||
@ -187,12 +212,20 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
}
|
||||
|
||||
function disableMarketing() {
|
||||
// Example implementation
|
||||
// You would implement according to your specific marketing cookies
|
||||
// Example implementation for common marketing cookies
|
||||
var marketingCookies = ['_fbp', 'fr', 'IDE', 'MUID', 'personalization_id'];
|
||||
var domains = [window.location.hostname, '.' + window.location.hostname];
|
||||
|
||||
marketingCookies.forEach(function(cookie) {
|
||||
domains.forEach(function(domain) {
|
||||
document.cookie = cookie + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT; Domain=' + domain;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function enableMarketing() {
|
||||
// Example implementation
|
||||
// You would implement according to your specific marketing cookies
|
||||
// For enabling marketing, we typically don't need to do anything special
|
||||
// The marketing scripts will set their cookies when they load
|
||||
// Just ensure the marketing scripts are loaded after checking consent
|
||||
}
|
||||
});
|
@ -14,6 +14,13 @@
|
||||
<div class="gdpr-cookie-modal-body">
|
||||
<p>{$gdprCookieMessage}</p>
|
||||
|
||||
<div class="gdpr-cookie-info-block">
|
||||
<p><strong>{l s='Data Controller:' mod='gdprcookieconsent'}</strong> {$gdprCookieDataController}</p>
|
||||
<p><strong>{l s='Cookie Retention Period:' mod='gdprcookieconsent'}</strong> {$gdprCookieRetentionPeriod}</p>
|
||||
<p><strong>{l s='Third-Party Recipients:' mod='gdprcookieconsent'}</strong> {$gdprCookieThirdParties}</p>
|
||||
<p><strong>{l s='Your Rights:' mod='gdprcookieconsent'}</strong> {l s='You can withdraw your consent at any time by clicking the "Manage Cookie Preferences" button or by deleting cookies in your browser settings.' mod='gdprcookieconsent'}</p>
|
||||
</div>
|
||||
|
||||
<div class="gdpr-cookie-categories">
|
||||
<div class="gdpr-cookie-category">
|
||||
<input type="checkbox" id="gdpr-cookie-necessary" checked disabled>
|
||||
@ -51,10 +58,18 @@
|
||||
<div id="gdpr-cookie-banner" class="gdpr-cookie-banner">
|
||||
<div class="gdpr-cookie-banner-content">
|
||||
<p>{$gdprCookieMessage}</p>
|
||||
<div class="gdpr-cookie-banner-info">
|
||||
<p><small><strong>{l s='Data Controller:' mod='gdprcookieconsent'}</strong> {$gdprCookieDataController} |
|
||||
<strong>{l s='Retention:' mod='gdprcookieconsent'}</strong> {$gdprCookieRetentionPeriod}</small></p>
|
||||
</div>
|
||||
<div class="gdpr-cookie-banner-buttons">
|
||||
<button id="gdpr-cookie-banner-decline" class="gdpr-cookie-banner-decline">{$gdprCookieDecline}</button>
|
||||
<button id="gdpr-cookie-banner-settings" class="gdpr-cookie-banner-settings">{$gdprCookieSettings}</button>
|
||||
<button id="gdpr-cookie-banner-accept" class="gdpr-cookie-banner-accept">{$gdprCookieAccept}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="gdpr-cookie-manage-button" class="gdpr-cookie-manage-button" style="display: none;">
|
||||
<button id="gdpr-cookie-manage" class="gdpr-cookie-manage">{$gdprCookieManageText}</button>
|
||||
</div>
|
11
views/templates/hook/manage_button.tpl
Normal file
11
views/templates/hook/manage_button.tpl
Normal file
@ -0,0 +1,11 @@
|
||||
{*
|
||||
* GDPR Cookie Consent Module for PrestaShop
|
||||
*
|
||||
* @author Walzen665
|
||||
* @copyright Copyright (c) 2025
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
*}
|
||||
|
||||
<div id="gdpr-cookie-manage-button" class="gdpr-cookie-manage-button" style="display: none;">
|
||||
<button id="gdpr-cookie-manage" class="gdpr-cookie-manage">{$gdprCookieManageText}</button>
|
||||
</div>
|
Reference in New Issue
Block a user