Results 1 to 5 of 5
  1. #1
    Join Date
    May 2004
    Location
    UK
    Posts
    478
    Plugin Contributions
    0

    Default How to get user name display on every page?

    I am trying to get "Hi <users name> " in the header of my shop - along the lines of the logout/account button - trying to make it more personal

    So it would Say

    Hi Sarah | Your Account | Your Basket £2.00 5 items

    But I have no idea how I can get that "name" inserted? Tried various firstname php calls and none work - I can see %s is used for the "greet user" section - but doesn't copy across either

    Thanks
    Sarah

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: How to get user name display on every page?

    You could use the session variable:
    $_SESSION['customer_first_name']
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    May 2004
    Location
    UK
    Posts
    478
    Plugin Contributions
    0

    Default Re: How to get user name display on every page?

    Thank you sometimes I am truly thick :) the only thing I didn't try!

    Is there a list/detail of what details we have stored in the sessions?

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: How to get user name display on every page?

    You could add, temporarily to the:
    /includes/templates/template_default/common/tpl_header.php

    the code in RED:
    Code:
    <?php
    echo '<pre>'; echo print_r($_SESSION); echo '</pre>';
    ?>
    <?php
      // Display all header alerts via messageStack:
    NOTE: check if you have:
    /includes/templates/your_template_dir/common/tpl_header.php

    as an override and if you do add it there ...

    Then, login and you can see the $_SESSION variables that exist ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: How to get user name display on every page?

    Quote Originally Posted by SarahL View Post
    I am trying to get "Hi <users name> " in the header of my shop - along the lines of the logout/account button - trying to make it more personal

    So it would Say

    Hi Sarah | Your Account | Your Basket £2.00 5 items

    But I have no idea how I can get that "name" inserted? Tried various firstname php calls and none work - I can see %s is used for the "greet user" section - but doesn't copy across either

    Thanks
    Sarah
    Just to add some formatting, this site http://torontogoldsilver.com/ uses this code:

    includes/templates/YOUR_TEMPLATE/common/tpl_header.php

    <div class="headerGreeting">
    <?php if ($_SESSION['customer_id']) {
    echo 'Hello ' . $_SESSION['customer_first_name'] . '!';
    } else {
    echo 'Welcome!';
    }?>
    </div>

    This shows 'Welcome!' for guests and once you're logged in adds 'Hello (First Name)'

    You can then set the CSS style for .headerGreeting as you wish.
    Twitch.
    https://www.twitchtoo.com Do you work for free? Please donate.
    Twitch Base8 - Obsidian - This, is what's new.

 

 

Similar Threads

  1. display user name in nav bar once logged in
    By Sushigal in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 7 Jul 2010, 11:02 AM
  2. How to display Category name or Product name as a tagline?
    By ttmb33 in forum General Questions
    Replies: 0
    Last Post: 19 Jan 2010, 05:47 PM
  3. Replies: 2
    Last Post: 30 Dec 2008, 12:22 PM
  4. Display New Product on every page?
    By mgrunt in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 7 Jun 2006, 06:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg