How can I display the name of a logged in customer in the header?
I want to display something like Hello, John Doe.
Thank you in advance!

Code: Select all
<?php if ($this->customer->isLogged()) { ?>
Welcome <?php echo $this->customer->getFirstName(); ?> <?php echo $this->customer->getLastName(); ?>, Enjoy your stay!
<?php } ?>
It does not need an update, in this section, because this here is the V.1.5.x - Zone.javox wrote:Anyone has any update on this? Looks as if in V2 doesn't work.
My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
Code: Select all
public function index () {
Code: Select all
if ($this->customer->isLogged()) {
$data['welcome_message'] = sprintf("Welcome %s %s, Enjoy your stay!", $this->customer->getFirstName(), $this->customer->getLastName());
}
Code: Select all
<?php if (isset($welcome_message)) { echo $welcome_message; } ?>
Code: Select all
public function index() {
if ($this->customer->isLogged()) {
$data['welcome_message'] = sprintf("Welcome %s, Enjoy your stay!", $this->customer->getFirstName());
}
My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
Qphoria wrote:2.0 doesn't allow direct calls to libraries from the tpl.
For 2.0 you need to add it to the controller and set a view variable.
1. EDIT: catalog/controller/common/header.php
2. FIND:3. AFTER, ADD:Code: Select all
public function index () {
4. EDIT: catalog/view/theme/YOURTHEME/template/common/header.tplCode: Select all
if ($this->customer->isLogged()) { $data['welcome_message'] = sprintf("Welcome %s %s, Enjoy your stay!", $this->customer->getFirstName(), $this->customer->getLastName()); }
5. PUT THIS WHERE YOU WANT IT:Code: Select all
<?php if (isset($welcome_message)) { echo $welcome_message; } ?>
Hi,raptorheli wrote:Done this as described , but it is not working in OC 2.1.0.2
What is wrong here, pls advice
EDIT: catalog/controller/common/header.php
2. FIND:
CODE: SELECT ALL
public function index () {
3. AFTER, ADD:
CODE: SELECT ALL
if ($this->customer->isLogged()) {
$data['welcome_message'] = sprintf("Welcome %s %s, Enjoy your stay!", $this->customer->getFirstName(), $this->customer->getLastName());
}
4. EDIT: catalog/view/theme/YOURTHEME/template/common/header.tpl
5. PUT THIS WHERE YOU WANT IT:
CODE: SELECT ALL
<?php if (isset($welcome_message)) { echo $welcome_message; } ?>
Code: Select all
$_['text_logged'] = 'You are logged in as <b><a href="%s">%s</a></b> <b>(</b> <a href="%s">Logout</a> <b>)</b>';
$_['text_welcome'] = 'Welcome visitor you can <a href="%s">login</a> or <a href="%s">create an account</a>.';
$_['text_welcome'] = 'Welcome!';
Code: Select all
$data['text_welcome'] = sprintf($this->language->get('text_welcome'), $this->url->link('account/login', '', 'SSL'), $this->url->link('account/register', '', 'SSL'));
Code: Select all
<?php if ($logged) { ?>
<?php echo $text_logged; ?>
<?php } else { ?>
<?php echo $text_welcome; ?>
<?php } ?>
My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
My Github OC Site: https://github.com/IP-CAM
5'600 + FREE OC Extensions, on the World's largest private Github OC Repository Archive Site.
Code: Select all
$data['firstname'] = $this->customer->getFirstName();
$data['lastname'] = $this->customer->getLastName();
Code: Select all
<?php if ( $logged ) { ?>
<span><?php echo $firstname; ?> <?php echo $lastname; ?></span>
<?php } else { ?>
<span>Sign/Register</span>
<?php } ?>
Users browsing this forum: No registered users and 7 guests