Jump to content

Set catalog mode ON/OFF if user unlogged/logged

Recommended Posts



I'm working on a prestashop module to set the catalog mode ON or OFF if user is unlogged or logged.

Works great but got a problem.

I don't want unlogged users see prices at all but with this solution, when unlogged user load the page, the catalog mod turn ON, but he can see prices (has to reload to hide prices) So, first load set catalog mode ON and second load display real catalog mode.

I found a js script to reload automatically the page to take effect with the new mode but obviously, loading time of the page is two times longer.

Here is the function :

public function hookHeader()
    $logged = $this->context->customer->isLogged();
    if (!$logged) {
        Configuration::updateValue('PS_CATALOG_MODE', true);
    } else {
        Configuration::updateValue('PS_CATALOG_MODE', false);
    // reload the page once more
    echo '
      <script type="text/javascript">
        (function() {
          if( window.localStorage ) {
            if( !localStorage.getItem( "firstLoad" ) ) {
              localStorage[ "firstLoad" ] = true;
            } else {
              localStorage.removeItem( "firstLoad" );

Hope somebody could help me with this. Thank you.


Share this post

Link to post
Share on other sites

have you considered just not showing prices to 'visitors'?


this can be accomplished


back office-->customers-->groups-->edit visitor-->set hid prices enabled

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More