Page 3 of 3

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Wed Jul 14, 2010 8:48 am
by Maansy
Fixed, had to do the CSS for that :)

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Sun Sep 05, 2010 2:46 pm
by silanli_53
fido-x wrote:
silanli_53 wrote:How can we show the surname.?

welcome; name lastname
Use this in the header controller (catalog/controller/common/header.php):

Code: Select all

// Greeting in header
if (!$this->customer->isLogged()) {
    $this->data['text_greeting'] = $this->language->get('text_greeting');
} else {
    $this->data['text_greeting'] = sprintf($this->language->get('text_logged'), $this->customer->getFirstName() . ' ' . $this->customer->getLastName());
}
$this->data['text_create'] = $this->language->get('text_create');
$this->data['create'] = HTTPS_SERVER . 'index.php?route=account/create';
// End Greeting in header    
Thanks fido-x

How do I add is in which group.?

Thanks
best regarts

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Wed Sep 08, 2010 7:02 am
by DannyMacD
Hi Fido and all.

is this 1.4.9 compatible?

many thanks

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Thu Sep 09, 2010 8:44 pm
by fido-x
DannyMacD wrote:Hi Fido and all.

is this 1.4.9 compatible?

many thanks
Yes.

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Mon Oct 18, 2010 10:57 pm
by Tom52
fido-x wrote:I've had a few requests for this from people who have visited my dev site. Since this is not mine (it's something that was in version 0.7.7), I'm quite happy to post the necessary information to get it working.

You will need to edit the following files:–
* catalog/controller/common/header.php
* catalog/language/english/common/header.php
* catalog/view/theme/default/template/common/header.tpl
* catalog/view/theme/default/stylesheet/stylesheet.css

catalog/controller/common/header.php
Insert the following:–

Code: Select all

if (!$this->customer->isLogged()) {
	$this->data['text_greeting'] = $this->language->get('text_greeting');
} else {
	$this->load->model('account/customer');
	$customer_info = $this->model_account_customer->getCustomer($this->customer->getId());
	$this->data['text_greeting'] = sprintf($this->language->get('text_logged'), $customer_info['firstname']);
}
$this->data['text_create'] = $this->language->get('text_create');
$this->data['text_account'] = $this->language->get('text_account');
$this->data['create'] = $this->url->https('account/create');
$this->data['account'] = $this->url->https('account/account');
before:

Code: Select all

$this->id       = 'header';
(around line 31 in an unmodified setup)

catalog/language/english/common/header.php
Insert the following:–

Code: Select all

$_['text_greeting'] = 'Welcome, <strong>Guest</strong>';
$_['text_logged']   = 'Welcome back, <strong>%s</strong>';
$_['text_create']   = 'Register';
$_['text_account']  = 'Account';
before the end of the file.

catalog/view/theme/default/template/common/header.tpl
Insert the following:–

Code: Select all

<div class="welcome">
  <?php echo $text_greeting; ?>
  <?php if (!$logged) { ?>
    [ <a href="<?php echo $login; ?>"><?php echo $text_login; ?></a> ] [ <a href="<?php echo $create; ?>"><?php echo $text_create; ?></a> ]
  <?php } else { ?>
    [ <a href="<?php echo $logout; ?>"><?php echo $text_logout; ?></a> ] [ <a href="<?php echo $account; ?>"><?php echo $text_account; ?></a> ]
  <?php } ?>
</div>
before

Code: Select all

<div class="div4">
catalog/view/theme/default/stylesheet/stylesheet.css
Add the following:–

Code: Select all

#header .welcome {
	clear: both;
	margin: 10px 0px 10px 0px;
	text-align: right;
}
At the end of the file.

Enjoy!
Hello,

The Header.php code, do I add it before or after $this->id = 'header"? because I tried, but its not working.

any help please :(

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Sat Oct 23, 2010 5:53 am
by DannyMacD
fido-x wrote:
DannyMacD wrote:Hi Fido and all.

is this 1.4.9 compatible?

many thanks
Yes.
im now confused at what code to use for 1.4.9.1 lol anyone throw me a bone please :) thanks :laugh:

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Fri Dec 10, 2010 12:37 am
by manson
For OC 1.4.9.2
With so many codes flying around I think many of us was confused. Here's just a compilation of what Fido coded for 1.4.9.2 users:

catalog/controller/common/header.php
Insert the following:–

Code: Select all

// Greeting in header
if (!$this->customer->isLogged()) {
    $this->data['text_greeting'] = $this->language->get('text_greeting');
} else {
    $this->data['text_greeting'] = sprintf($this->language->get('text_logged'), $this->customer->getFirstName());
}
$this->data['text_create'] = $this->language->get('text_create');
$this->data['create'] = HTTPS_SERVER . 'index.php?route=account/create';
// End Greeting in header    
before:

Code: Select all

$this->id       = 'header';
catalog/language/english/common/header.php
Insert the following:–

Code: Select all

$_['text_greeting'] = 'Welcome, <strong>Guest</strong>';
$_['text_logged']   = 'Welcome back, <strong>%s</strong>';
$_['text_create']   = 'Register';
$_['text_account']  = 'Account';
before the end of the file.

catalog/view/theme/default/template/common/header.tpl
Insert the following:–

Code: Select all

<div class="welcome">
  <?php echo $text_greeting; ?>
  <?php if (!$logged) { ?>
    [ <a href="<?php echo $login; ?>"><?php echo $text_login; ?></a> ] [ <a href="<?php echo $create; ?>"><?php echo $text_create; ?></a> ]
  <?php } else { ?>
    [ <a href="<?php echo $logout; ?>"><?php echo $text_logout; ?></a> ] [ <a href="<?php echo $account; ?>"><?php echo $text_account; ?></a> ]
  <?php } ?>
</div>
before

Code: Select all

<div class="div4">
catalog/view/theme/default/stylesheet/stylesheet.css
Add the following:–

Code: Select all

#header .welcome {
    float: right;
    display: block;
    margin-top: 7px;
    margin-bottom: 10px;
    padding-left: 0px;
}
#header .welcome a {
    margin: 0px;
    padding: 0px;
    background: none;
}
 
At the end of the file.

And that's it, hope I didn't screw the code with the cut and paste. I put the Greeting messages on the right side along the lines of [Specials] [Bookmark] [Contact] and align the top to 7px, as the rest of the wordings.

Thanks Fido for the codes!

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Sun May 29, 2011 4:32 am
by elaineben
after pasting all the siles to their respective places...i got this error upon opening my site:


Fatal error: Call to a member function https() on a non-object in /home/abcd12/public_html/ocart/catalog/controller/common/header.php on line 182


what does it mean?

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Wed Aug 17, 2011 1:51 am
by spitos
I've got something similar to this working for v1.5.x
It adds a personalised welcome message after login to both the account and affiliate account pages.
You can download it (commercial) here:
http://www.opencart.com/index.php?route ... on_id=3946

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Fri Aug 26, 2011 7:46 am
by asphole
Hi spitos,

I just checked your vqmod and it works well for 1.5.1. A nice little addition i'm sure others will use.

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Thu Oct 18, 2012 11:29 pm
by pooks
How can I get this to frontpage body? I tried to duplicate this to home files but didnt work out...

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Tue Dec 23, 2014 9:51 pm
by cronolead
Please update the code for 2.x.x version

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Sat May 23, 2015 2:17 pm
by lacostechiu
I want to know how to show the customer name and welcom message in header, after logged.

I find the solution in stackoverflow, not worked, but I think it's almost.

anyone help ?

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Mon Sep 21, 2015 2:36 pm
by embuh
Thank problem solve
Toko Mainan Surabaya

Re: [HOW TO] - Welcome Message / Customer Name in Header

Posted: Fri Dec 23, 2016 3:33 pm
by salwa123
is this oc 2.3.0.2 compatible?