Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't install the module on prestashop #1

Open
webdonchi opened this issue Aug 2, 2021 · 9 comments
Open

can't install the module on prestashop #1

webdonchi opened this issue Aug 2, 2021 · 9 comments

Comments

@webdonchi
Copy link

hi, on ps 1.7.6.7 i can't install your module with the method "add a module", can you check please?

@samoa
Copy link

samoa commented Jan 8, 2022

I installed it, simply download zip source code, unpack, rename to eucookiesmart and copy to modules folder,
after that you will see it in modules manager and will be able to install it.

Unfortunately looks that module is not working,
I tried various combinations of settings, cleared cache, but it looks like lot of time spend without reasonable result :(

@yuxblank
Copy link
Owner

yuxblank commented Jan 8, 2022

Hi guys, probably something has changed in prestashop or there's some incompatibility between your theme and the module. I'll check it for new prestashop versions.

Do you use any third party theme? Does you have any error in the browser console referring to the module JavaScript code?

Thanks.

@samoa
Copy link

samoa commented Jan 9, 2022

Hello,
thank you for your reply,
in console I found

core.js:39 jQuery.Deferred exception: euCookieSmartConfig is not defined ReferenceError: euCookieSmartConfig is not defined at HTMLDocument.<anonymous> (http://localhost/prestashop_1778/modules/eucookiesmart/views/js/euCookieSmart.js:188:21) at c (http://localhost/prestashop_1778/themes/core.js:39:25650) at d (http://localhost/prestashop_1778/themes/core.js:39:25949) undefined T.Deferred.exceptionHook @ core.js:39

core.js:39 Uncaught ReferenceError: euCookieSmartConfig is not defined at HTMLDocument.<anonymous> (euCookieSmart.js:188) at c (core.js:39) at d (core.js:39)

I have custom theme but without problems with all modules,
using Prestashop 1.7.7.8

@yuxblank
Copy link
Owner

yuxblank commented Jan 9, 2022

I @samoa i've tested with 1.7.8.2 with a clean install and i have no problems whatsoever, i think it's due to the theme.
Try to type in the console euCookieSmartConfig and see if it output something, should have a configuration object.

If the console has no object it's due to the fact that the theme does not render HookDisplayFooter, you can try to change:

    public function hookDisplayHeader()
    {
        $this->context->controller->addJS($this->_path . 'views/js/euCookieSmart.js');
        $cssFile = Configuration::get("EUCOOKIESMART_STYLE");
        $this->context->controller->addCSS($this->_path . 'views/css/styles/' . ($cssFile ? $cssFile : 'default.css'));
    }

with:

    public function hookDisplayHeader()
    {
        $this->context->controller->addJS($this->_path . 'views/js/euCookieSmart.js');
        $cssFile = Configuration::get("EUCOOKIESMART_STYLE");
        $this->context->controller->addCSS($this->_path . 'views/css/styles/' . ($cssFile ? $cssFile : 'default.css'));
        return $this->HookDisplayFooter(); // this line is new
    }

should be enough to render the template that includes the configuration object.

the best way is to comment HookDisplayFooter code and copy it to the hookDisplayHeader method, this is safer if you change the theme to something that renders the footer or it will render twice.

If the configuration object is present than it migth be a problem of the loading order (document is initialized but the footer has not rendered yet), maybe the same solution above can apply for your theme.

@webdonchi the zip source of the github repository breaks the structure of Prestashop modules. to use the zip just unpack it, rename the inner directory to eucookiesmart and compress that inner folder. This new zip will work.

@samoa
Copy link

samoa commented Jan 9, 2022

Thank you,
it is displaying content now,
but decline button is missing, also I tried a various combinations but "Display decline button" still not visible.

Console is empty now.

I need it because of new EU regulations, that you must have options for decline cookies. :-(

Snímka obrazovky (14)
(

@yuxblank
Copy link
Owner

yuxblank commented Jan 9, 2022

@samoa yup there's a bug there.
i just updated the code:
https://github.com/yuxblank/EuCookieSmart/releases/tag/1.0

The euCookieSmart.tpl was not passing the decline button enable switch correctly.

Use the latest release or simply replace:

<script>

    var euCookieSmartConfig = {
        message: "{$cookieMsg}",
        acceptButton: "{$EUCOOKIESMART_BUTTON_ACCEPT}",
        acceptText: "{$cookieAcceptText|escape:"quotes"}",
        declineButton: false,
        declineText: "{$cookieDeclineText}",
        policyButton: "{$EUCOOKIESMART_BUTTON_POLICY}",
        policyText: "{$cookiePolicyText|escape:"quotes"}",
        policyURL: "{$policyCMSlink}",
        acceptOnContinue: "{$EUCOOKIESMART_ACCEPT_CONTINUE}",
        expireDays: "{$EUCOOKIESMART_EXPIRE_DAYS|escape:"quotes"}",
        renewOnVisit: "{$EUCOOKIESMART_RENEW_VISIT}",
        effect: "{$EUCOOKIESMART_EFFECT|escape:"quotes"}",
        fixed: "{$EUCOOKIESMART_FIXED|boolval}",
        bottom: "{$EUCOOKIESMART_BOTTOM}"
    };


</script>

with :

<script>

    var euCookieSmartConfig = {
        message: "{$cookieMsg}",
        acceptButton: "{$EUCOOKIESMART_BUTTON_ACCEPT}",
        acceptText: "{$cookieAcceptText|escape:"quotes"}",
        declineButton: {$EUCOOKIESMART_BUTTON_DECLINE},
        declineText: "{$cookieDeclineText}",
        policyButton: "{$EUCOOKIESMART_BUTTON_POLICY}",
        policyText: "{$cookiePolicyText|escape:"quotes"}",
        policyURL: "{$policyCMSlink}",
        acceptOnContinue: "{$EUCOOKIESMART_ACCEPT_CONTINUE}",
        expireDays: "{$EUCOOKIESMART_EXPIRE_DAYS|escape:"quotes"}",
        renewOnVisit: "{$EUCOOKIESMART_RENEW_VISIT}",
        effect: "{$EUCOOKIESMART_EFFECT|escape:"quotes"}",
        fixed: "{$EUCOOKIESMART_FIXED|boolval}",
        bottom: "{$EUCOOKIESMART_BOTTOM}"
    };


</script>

in euCookieSmart.tpl file.

@samoa
Copy link

samoa commented Jan 9, 2022

Now button is displayed,
but in fact not working,
cookies are created before and not enabled,
only change which system doing is setting "eucookiesmart" to declined,
but cookies for google analytics are already loaded.

Or should it disable another one cookies?

As I understood EU regulations it looks like cookies for google analytics are also not allowed without agreement.

By the way I renamed in eucookiesmart.js variable eucookiesmrt to eucookiesmart (a letter was missing),
it was not working before renaming so I think that I renamed it correctly,
in other case please let me know :-)

@yuxblank
Copy link
Owner

yuxblank commented Jan 9, 2022

@samoa that cookie index name doesn't change it's behavhiour.
The module does not prevent other cookies to being applied, you might want some more advanced modules to do that.
You can of course provide a fuction to do that by replacing the var cookieDecline = function.
read more here:
https://cookie-script.com/how-to-block-third-party-cookies.html

You can for instance prevent each module that set cookies to "act" only when the cookie has a value allowed and not declined.

When you decline the cookie, the eucookiesmart cookie will be valued as declined only.

Unfortunately you need to handle each provider within the provider code (for instance by wrapping their function or use script tag attributes), so modules that prevent all cookies usually hooks into many sdk's. (google analytics, facebook etc)

@webdonchi
Copy link
Author

I installed it, simply download zip source code, unpack, rename to eucookiesmart and copy to modules folder, after that you will see it in modules manager and will be able to install it.

Unfortunately looks that module is not working, I tried various combinations of settings, cleared cache, but it looks like lot of time spend without reasonable result :(

hi, yes the error is with my theme...infact with a clean installation it seems work, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants