Jump to content
  • 0
pedes

$cookie->customer_firstname and $cookie->customer_firstname always stay the same !

Question

if a customer logged in his/her name is visible at the top of the header (user info).

this first and last name should be the name of the logged customer, but for one or another reason this always stay the same.

The last name since the cache was empty before.

 

The first and last name are stored in a cookie, like:

{$cookie->customer_firstname} {$cookie->customer_lastname}

 

but it seems that this is no getting empty after ending the customers session.

 

Anyone has a clue how to fix this ?

 

Many thanks !

 

I'm using Prestashop v1.5.4.1, it was an upgrade from v1.4.8.

Edited by pedes

Share this post


Link to post
Share on other sites

25 answers to this question

Recommended Posts

  • 0

hi vekia, thank you for your reply.

 

I changed like you said:

{$cookie>customer_firstname} {$cookie->customer_lastname}

to

{$context->customer_firstname} {$context->customer_lastname}

 

but this is not working ... i have no names coming at all.

 

Any other suggestions ?

Share this post


Link to post
Share on other sites
  • 0

I have just checked the code in the fresh down loaded v1.5.4.1 and there they also use

{$cookie->customer_firstname} {$cookie->customer_lastname}

 

so it would be normal to use the $cookie tag.

 

But something els has to be wrong ... but what ?

Share this post


Link to post
Share on other sites
  • 0

if i turn off the cache in the advanced parameters tab it is working like it should be !

 

but how can i let it work with the cache turned on ?

Share this post


Link to post
Share on other sites
  • 0

okay i checked sources, you've got right.

it's really weird :/

 

it looks like cache issue.

 

have you got possibility to use mod_expires ? check this:

Well, here's the solution that worked for me.

 

1) via FTP find .htaccess file

2) edit it with Notepad and find the part with "<IfModule mod_expires.c>"

3) delete his content and add "ExpiresActive Off"

 

The resulting content should be

 

<IfModule mod_expires.c>

ExpiresActive Off

 

</IfModule>

 

from thread: http://www.prestashop.com/forums/topic/2547[spam-filter]new-products-dont-show-up-in-frontstore-unless-refreshing-browser/page__p__1271900__hl__mod_expires__fromsearch__1?do=findComment&comment=1271900

Share this post


Link to post
Share on other sites
  • 0

thanks for the reply ..

 

I have no succes on this ..

even with the .htaccess modification

<IfModule mod_expires.c>

ExpiresActive Off

</IfModule>

 

this is still not working :unsure:

Share this post


Link to post
Share on other sites
  • 0

hello, we have same issue with the last 4 prestashop sites we have been working, my clients are about to cancell my projects as i dont have any idea how to make the right logging name to appear, it is for sure a CACHE module issue, all works fine when you have cache disable or if you clean cache using a free module like this http://www.prestatoolbox.com/free-modules/122-clear-the-cache-of-prestashop.html , the problem is that you have to flush cache every day (which is not really a solution).

 

i have post the bug to prestashop forums (not answer yet).

 

maybe if we tell the cache to NOT cache the welcome module? anyone know how to make that happen? adding a line to avoid caching for that module only?

Share this post


Link to post
Share on other sites
  • 0

Hello, cessargor

I have notice this today when you have send mail to the support. This is happen due to some theme developer separate the my account content to other module. but the my account module add some smarty variable from php for that cookie value changed when login.

Share this post


Link to post
Share on other sites
  • 0

The things is that. Our old developer cut code of customer login information from blockuserinfo

{if $logged}
		 <li>  <a href="{$link->getPageLink('index', true, NULL, "mylogout")}" title="{l s='Log me out' mod='blockcurrencies'}">{$cookie->customer_lastname} ({l s='Log out' mod='blocksearch'})</a></li>
	{else}

		<li {if $page_name == 'authentication'} class="highlight" {/if} ><a href="{$link->getPageLink('my-account', true)}">{l s='Login'  mod='blocksearch'}</a></li>
	{/if}

 

and put to blocksearch for design match. In design the login information link is on top and cart information is side to menu.

 

But in blockuserinfo the bellow value is assigned in tpl

$this->smarty->assign(array(
  'cart' => $this->context->cart,
  'cart_qties' => $this->context->cart->nbProducts(),
  'logged' => $this->context->customer->isLogged(),
  'customerName' => ($this->context->customer->logged ? $this->context->customer->firstname.' '.$this->context->customer->lastname : false),
  'firstName' => ($this->context->customer->logged ? $this->context->customer->firstname : false),
  'lastName' => ($this->context->customer->logged ? $this->context->customer->lastname : false),
  'order_process' => Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc' : 'order'
 ));

 

If the site is cached the value also change customer login information to to the firstName and lastName is changed by the tpl. If the tpl code of blockuserinfo is shifted to other module then the customer login name is correct only when cache is disable. If cache is enable then the login name show last login customer name which is bug.

 

So the blockuserinfo and block cart need to put same ui place. Do you need any more information vekia :)

Edited by smartdatasoft

Share this post


Link to post
Share on other sites
  • 0

yeah! nope all is clear now, many thanks to you smartdatasoft, seems like the issue is solved ;D

vekia can you told one things. Although the veriable is not use on blockuserinfo.tpl which pass from the php page. How the customer name change when cache is enable.

and this value give wrong information when move to other tpl :)

{$cookie->customer_lastname}

Share this post


Link to post
Share on other sites
  • 0

I have the same problem, but I don´t understand how to fix. Please can you explain more.

 

Sorry by my english.

are you using the leisure theme developed by smartdatasoft if so then mail with your site url to support[.]smartdatsoft[.]com we will give further instruction of file to your to fix that.

Share this post


Link to post
Share on other sites
  • 0

You can send me the url or take a look it like this site.http://smartdatasoft.com/prestashop/leisure/fashion-shop if it like this site than the them was build by our team

Share this post


Link to post
Share on other sites
  • 0

Hello everyone,

 

I have encountered the same issue and I am trying to follow along what everyone is saying, but I am completely lost. I am so frustrated because we just launched our site one week ago and it is embarrasing. If anyone can give me a hand, I would be so thankful. My site is www.shopusa.cl.

 

Best regards.

Share this post


Link to post
Share on other sites
  • 0

Hello,Silly2127,

i replied your personal message. and you notice that i also wrote above that some code are inside the php code which change the blockcart.tpl's user information. so we need to put theme also in the theme module. which some theme developer do not know

Share this post


Link to post
Share on other sites
  • 0

Dear all.

 

in my old version of my template have this error.

But now with new version we fixed it

http://demo4leotheme.com/prestashop/leo_citymart/index.php

this error happened with using

 

Welcome | Log in | contact |sitemap | bookmark

 

 

 

 

 

 

 

by module blockpermanentlinks and prestashop cache customer login information.

 

So in new version, we change blockpermanentlinks by using blockuserinfo module to show customer login information.

if any people have this error, please download latest version of this template

Share this post


Link to post
Share on other sites
  • 0

Hello,

 

I'am using the prestashop wine theme PRS050110 and I'm facing the same problem. What do I need to change in the code? It is not clear to me.

 

Many thanks. 

Share this post


Link to post
Share on other sites
  • 0

Help Please!!

I have exactly this problem using 1.5.6.2.  It only occurs in my theme not the default. I am not able to get back to the developers. Can someone explain, in simple langauge, how to correct it.

 

many thanks

John

Share this post


Link to post
Share on other sites
  • 0

Hi,

And thanks a lot, for all informations

 

You can go there to find more  : http://forge.prestashop.com/browse/PSCFV-9543

 

In my case, I have to work with pos optima digital theme, I dunno if it was modified or if it is the work of the theme developper but

'Welcome message customer name' has been moved to blockcontact nav.tpl but to work it should stay in blockuserinfo nav.tpl or be placed in tpl where variables values are allways updated.

 

I think that when cache is used, blockcontact is considered as 'very static'.

Think of highly dynamic fields and static ones like the shopname for example. Shopname may never change then no need to update cache.

 

Why it runs like this without problem on some shop ?

In my case smarty settings were let in 'Force compilation everytime' and 'No cache'.

 

Good luck to fix it in your theme.

Math

Edited by math_php

Share this post


Link to post
Share on other sites
  • 0

Okay guys, ready to buy a quick and dirty fix ?

 

I found a way to force 'static cache' to become 'dynamic cache' :

 

As my 'welcome User name' has been placed in my case in blockcontact, the code before the fix is :

 

modules/blockcontact/blockcontact.php

public function hookDisplayRightColumn($params)
    {
        global $smarty;
        $tpl = 'blockcontact';
        if (isset($params['blockcontact_tpl']) && $params['blockcontact_tpl'])
            $tpl = $params['blockcontact_tpl'];
        if (!$this->isCached($tpl.'.tpl', $this->getCacheId()))
                    
                        $smarty->assign(array(
                'telnumber' => Configuration::get('BLOCKCONTACT_TELNUMBER'),
                'email' => Configuration::get('BLOCKCONTACT_EMAIL')
            ));
        return $this->display(__FILE__, $tpl.'.tpl', $this->getCacheId());
                        return $this->display(__FILE__, $tpl.'.tpl');
    }

After messing the stuff to force update :

public function hookDisplayRightColumn($params)
    {
        global $smarty;
        $tpl = 'blockcontact';
        if (isset($params['blockcontact_tpl']) && $params['blockcontact_tpl'])
            $tpl = $params['blockcontact_tpl'];
        if (1 || !$this->isCached($tpl.'.tpl', $this->getCacheId()))
    
                
                        $smarty->assign(array(
                'telnumber' => Configuration::get('BLOCKCONTACT_TELNUMBER'),
                'email' => Configuration::get('BLOCKCONTACT_EMAIL')
            ));
        //return $this->display(__FILE__, $tpl.'.tpl', $this->getCacheId());
         return $this->display(__FILE__, $tpl.'.tpl');
    }

Focus on isCached( and getCacheId( to get it.

 

Cheers

Edited by math_php

Share this post


Link to post
Share on other sites
  • 0

You can do it also like this:

 

modules/blockcontact/blockcontact.php

 public function hookDisplayRightColumn($params) {
        global $smarty;
        $tpl = 'blockcontact';
        if (isset($params['blockcontact_tpl']) && $params['blockcontact_tpl'])
            $tpl = $params['blockcontact_tpl'];
// ADD THIS LINES
// assign customer firstname and lastname before caching tempate
        $smarty->assign(array(
            'customer_firstname' => $this->context->customer->firstname,
            'customer_lastname' => $this->context->customer->lastname,
        ));
// END
        if (!$this->isCached($tpl . '.tpl', $this->getCacheId()))
            $smarty->assign(array(
                'telnumber' => Configuration::get('BLOCKCONTACT_TELNUMBER'),
                'email' => Configuration::get('BLOCKCONTACT_EMAIL'),
                'customer_firstname' => $this->context->customer->firstname,
                'customer_lastname' => $this->context->customer->lastname,
            ));
        return $this->display(__FILE__, $tpl . '.tpl', $this->getCacheId());
    }

and then in template (e.g. themes/default-theme/modules/blockcontact/nav.tpl) use {nocache}{/nocache} smarty function to customer firstname and lastname:

{nocache}{$customer_firstname} {$customer_lastname}{/nocache}

Share this post


Link to post
Share on other sites

×