Answer the question
In order to leave comments, you need to log in
How to display the buyer's name on the header in Opencart?
Good afternoon, gentlemen,
I was given the task to display the name and surname of an authorized user in a certain place on the header. I googled and many times. Found different ways, tried them and nothing worked.
I in one of the solutions it was said like this:
In the header.php in the folder along the path opencart/catalog/controller/common/ and add the lines:
$data['firstname'] = $this->customer->getFirstName();
$data['lastname'] = $this->customer->getLastName();
<?php echo $firstname; ?>
<?php echo $lastname; ?>
Answer the question
In order to leave comments, you need to log in
check first in the controller whether the variables are defined or not
above this line
$data['firstname'] = $this->customer->getFirstName();
to be sure, check also $this->customer->getId()
write down
echo $this->customer->isLogged()."-".$this->customer->getId()."-".$this->customer->getFirstName()."-".$this->customer->getLastName(); exit;
if ($this->customer->isLogged()) {
$data['firstname'] = $this->customer->getFirstName();
$data['lastname'] = $this->customer->getLastName();
} else {
$data['firstname'] = '';
$data['lastname'] = '';
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question