Author Topic: Show customer name after login  (Read 5625 times)

Offline behold

  • Newbie
  • *
  • Posts: 15
  • Karma: +1/-0
    • View Profile
Show customer name after login
« 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
« Last Edit: February 13, 2014, 08:17:25 PM by cmurphy060960 »

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Show customer name after login
« Reply #1 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.
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

Offline behold

  • Newbie
  • *
  • Posts: 15
  • Karma: +1/-0
    • View Profile
Re: Show customer name after login
« Reply #2 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?

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: Show customer name after login
« Reply #3 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
Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

 

Powered by SMFPacks Social Login Mod