Hi,
i would like to display the customer email in the header bar when he is logged in.
Something like this:
Logged as: customer@customer.com
I´ve tried to do this but i can´t
Can u help me?
Thank u in advance
i would like to display the customer email in the header bar when he is logged in.
Something like this:
Logged as: customer@customer.com
I´ve tried to do this but i can´t
Can u help me?
Thank u in advance
Open: catalog\controller\common\header.php
Update your file with the following mod:
Now open: catalog\view\default\template\common\header.tpl
Add this line wherever you want to display the user's email address:
Let me know how that works out for you.
-Chris
Update your file with the following mod:
Code: Select all
class ControllerCommonHeader extends Controller {
protected function index() {
$this->language->load('common/header');
/* Mod (show customer email) */
if ($this->customer->isLogged()){
$this->load->model('account/customer');
$customer_info = $this->model_account_customer->getCustomer($this->customer->getId());
if (isset($customer_info)) {
$this->data['email'] = $customer_info['email'];
} else {
$this->data['email'] = '';
}
}
/* End Mod */
$this->data['store'] = $this->config->get('config_store');
Add this line wherever you want to display the user's email address:
Code: Select all
<?php echo($email); ?>
-Chris
PM me for custom OpenCart template design and development.
It doesn't work if the client didn't log in the account.huhitschris wrote:Open: catalog\controller\common\header.php
Update your file with the following mod:
I know nothing about PHP and SQL, but I still try my best to understand it.
Ahh, good catch!
I forgot to mention that header.tpl uses the $logged variable to determine if a user is logged in, so using an IF statement around this variable can help you display the user's email or display a generic "not logged in" message or whatever you prefer.
Something like this should work:
I forgot to mention that header.tpl uses the $logged variable to determine if a user is logged in, so using an IF statement around this variable can help you display the user's email or display a generic "not logged in" message or whatever you prefer.

Something like this should work:
Code: Select all
<?php if (!$logged) { ?> Not Logged In <?php } else { echo $email; } ?>
PM me for custom OpenCart template design and development.
Who is online
Users browsing this forum: No registered users and 1 guest