Magento: how do I use the echo username

I use a modern theme

I have a livechat button in the header and I want to parse the information in my template

This is the livechat button:

<!-- http://www.LiveZilla.net Chat Button Link Code --><a href="[removed]void(window.open('http://xxxxxx.fr/livezilla.php?code=BOUTIQUE&amp;en=<!!CUSTOMER NAME!!>&amp;ee=<!!!CUSTOMER EMAIL!!>......... 

I need to replace both the name and email address of the user (if registered)

The button is in the title bar of my homepage.

How do I repeat these two information?

I tried

 <?php echo $this->htmlEscape($this->getCustomer()->getName()) ?> 

but did not work:

Fatal error: calling the member function getFirstname () for a non-object in / home / xxx / public _html / app / design / frontend / default / modern / template / page / html / header.phtml on line 36

+4
source share
1 answer

this is normal. The block corresponding to the template app/design/frontend/default/modern/template/page/html/header.phtml is located in app/code/Core/Page/Block/Html/Header.php .

If you read the block code, you will see that there is no "getCustomer ()" function. And when you try to call $this->getCustomer()->getName(); on the template page, since the getCustomer () function does not exist, it returns nothing.

As a result, you try to call "getName ()" nothing ... and an error message appears: Fatal error: Call to a member function getFirstname() on a non-object .

As you can read: Calling the member function getFirstname () on a non-object .

If you want to get the client name in header.phtml, you should:

 $session = Mage::getSingleton('customer/session'); if($session->isLoggedIn()) { $customer = $session->getCustomer(); echo $customer->getName(); echo $customer->getFirstname(); } 

Hyuug.

+9
source

Source: https://habr.com/ru/post/1312636/


All Articles