From b14b3650d03ac32b51bdb980c4dda14974f3a8eb Mon Sep 17 00:00:00 2001 From: "ivan.hrytsai" Date: Tue, 3 Mar 2026 16:40:20 +0200 Subject: [PATCH] 14847-Dispatch-Consent-Event --- .../js/isCustomerConsentProvided.phtml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/view/base/templates/js/isCustomerConsentProvided.phtml b/view/base/templates/js/isCustomerConsentProvided.phtml index 5a4496b..e1c7db5 100644 --- a/view/base/templates/js/isCustomerConsentProvided.phtml +++ b/view/base/templates/js/isCustomerConsentProvided.phtml @@ -56,5 +56,26 @@ if (!isset($escaper)) { return false; }; + + window.MagefanJs.dispatchConsentEvent = function() { + var allowedGroups = MagefanJs.getCookie('mf_cookie_groups'); + var disallowedGroups = MagefanJs.getCookie('mf_cookie_groups_disallowed'); + + document.dispatchEvent(new CustomEvent('mf:consentReady', { + detail: { + consented: MagefanJs.isCustomerConsentProvided(), + allowedGroups: allowedGroups === 'all' ? 'all' : (allowedGroups ? allowedGroups.split(',') : []), + disallowedGroups: disallowedGroups ? disallowedGroups.split(',') : [] + } + })); + }; + + document.addEventListener('DOMContentLoaded', function() { + window.MagefanJs.dispatchConsentEvent(); + }); + + document.addEventListener('mf:initCookiesListener', function() { + window.MagefanJs.dispatchConsentEvent(); + }); "; ?> renderTag('script', $block->getScriptAttributes() ?: [], $script, false) ?>