AbanteCart Community

Shopping Cart Operations => Support => General Support => Topic started by: behold on February 13, 2014, 08:12:41 PM

Title: Show customer name after login
Post by: behold on February 13, 2014, 08:12:41 PM
Using V 1.1.7
Revisiting an old post.
Original post: http://forum.abantecart.com/index.php/topic,1039.msg3954.html#msg3954

After logging in, I'd like to be able to have the customer's name appear in the header of every page. Something to the effect; Welcome "Customer Name."

The customers first name does appear on the customers account dashboard.

In... storefront/view/default_html5/template/pages/account/account.tpl
is the code... <span class="subtext"><?php echo $customer_name; ?></span>

In... storefront/controller/pages/account/account.php
is the code... $this->data['customer_name'] = $this->customer->getFirstName();

Would either of these work? The question is, now what? Is this a simple matter of creating a new block? If so what additional HTML/code is required?

I'm fairly novice so would appreciate if someone could walk me through this.

Many thanks in advance.

Chris
Title: Re: Show customer name after login
Post by: abantecart on February 13, 2014, 08:54:42 PM
You are on the right track.
Customer object is loaded all the time after the customer is logged in.
You can check if customer is logged in with
Code: [Select]
$this->customer->isLogged()
If you need to show on every page, you better add this to storefront/controller/common/header.php and somewhere in /storefront/view/default_html5/template/common/header.tpl
Header is common in all storefront pages.
If that does not work you can create new block with controller/template files and assign it where is needed.
Title: Re: Show customer name after login
Post by: behold on February 13, 2014, 10:14:52 PM
Thank you for your prompt reply. I'm afraid you've already lost me :-[

$this->customer->isLogged()
this goes in a DIV on the pages you referenced?

Also, the code checks whether a customer is logged in - will it also display the customers name?
Title: Re: Show customer name after login
Post by: abantecart on February 13, 2014, 10:21:23 PM
This code can go to controller, but it also can be use in template.
It will not show you the customer name, but you need to check if customer is logged in before you check the name

To show the name use $this->customer->getFirstName and $this->customer->getLastName