Zen Cart Logo
Forums / General Questions / Customer Last Name

Customer Last Name

Views: 1,591

Results 1 to 14 of 14
16 Dec 2011, 1:56 AM
#1
goldfox avatar

goldfox

New Zenner

Join Date:
Dec 2011
Posts:
18
Plugin Contributions:
0

Customer Last Name

HALP!

I'm stuck in a loop here guys. This seems very rudimentary, and I've found a few threads that seem to answer my exact problem, but the code isn't working when I try to implement it.

I want a customer greeting to read:

"Logged in as First name Last name."

I have at the moment:

Logged in as <?php echo zen_output_string_protected($_SESSION['customer_first_name']); ?> <?php echo zen_output_string_protected($_SESSION['customer_last_name']); ?>.

The first name is working, but the last name isn't.

I've checked the modules/pages/login/header_php.php, and last name IS being checked into $_SESSION.

Sorry to ask a dumb question, but I've been failing for hours.

-Chris

16 Dec 2011, 2:05 AM
#2
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Customer Last Name

Where, as in what file, have you added that too?

16 Dec 2011, 2:14 AM
#3
goldfox avatar

goldfox

New Zenner

Join Date:
Dec 2011
Posts:
18
Plugin Contributions:
0

Re: Customer Last Name

The header for my custom template:

includes/templates/my template name/common/tpl_header.php

-Chris

16 Dec 2011, 2:17 AM
#4
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Customer Last Name

Seems to work fine for me ...

Can you grab the code around it such as 5 lines above and 5 lines below and post it?

16 Dec 2011, 2:21 AM
#5
goldfox avatar

goldfox

New Zenner

Join Date:
Dec 2011
Posts:
18
Plugin Contributions:
0

Re: Customer Last Name

<div id="navMain"> <ul class="back" style="color:#c50006"> <?php if ($_SESSION['customer_id']) { ?> <li style="float:left; font-size:14px;"">

Logged in as <a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>" style="padding:0px;"><?php echo zen_output_string_protected($_SESSION['customer_first_name']); ?> <?php echo zen_output_string_protected($address['lastname']); ?>.</a></li>
</ul>
</div>

Is there a cleaner way to paste code? This is my first time EVER on a development forum... I fear this will post completely unreadable.

-Chris

16 Dec 2011, 2:23 AM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Customer Last Name

Your code is using:

zen_output_string_protected($address['lastname'])

how about trying the session variable you asked about:

$_SESSION['customer_last_name']

See if that works better for you ... :smile:

16 Dec 2011, 2:25 AM
#7
goldfox avatar

goldfox

New Zenner

Join Date:
Dec 2011
Posts:
18
Plugin Contributions:
0

Re: Customer Last Name

Sorry I posted the wrong code. That was some fail thread that said to call $address. Which didn't work.

It was meant to be this:

<div id="navMain">
	<ul class="back" style="color:#c50006">
		<?php if ($_SESSION['customer_id']) { ?>
				<li style="float:left; font-size:14px;"">Logged in as <a href="<?php echo zen_href_link(FILENAME_ACCOUNT, '', 'SSL'); ?>" style="padding:0px;"><?php echo zen_output_string_protected($_SESSION['customer_first_name']); ?> <?php echo zen_output_string_protected($_SESSION['customer_last_name']); ?>.</a></li>
	</ul>
</div>
16 Dec 2011, 2:28 AM
#8
goldfox avatar

goldfox

New Zenner

Join Date:
Dec 2011
Posts:
18
Plugin Contributions:
0

Re: Customer Last Name

... which still isn't working my end. :'(

16 Dec 2011, 2:32 AM
#9
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Customer Last Name

Your code works great for me ...

Can you peek in the:
/includes/modules/pages/login/header_php.php

do you have this code on around line 87:

        $_SESSION['customer_last_name'] = $check_customer->fields['customers_lastname'];

Can you check the account that you are working with and make sure that there is a lastname set on it?

Could you also check in phpMyAdmin for the table:
address_book

and make sure that there is a last name in the field:
entry_lastname

for that customer?

16 Dec 2011, 2:37 AM
#10
goldfox avatar

goldfox

New Zenner

Join Date:
Dec 2011
Posts:
18
Plugin Contributions:
0

Re: Customer Last Name

I have that exact code on my line 87 of header_php.php.

Also checked there is definitely a lastname set. It shows up in the account settings and if I call the full address label.
And it shows up in the Active Users in the site admin.

Totally bamboozled! :p

16 Dec 2011, 2:39 AM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Customer Last Name

Just for giggles and grins ... could we perhaps have a peek at your site?

16 Dec 2011, 2:41 AM
#12
goldfox avatar

goldfox

New Zenner

Join Date:
Dec 2011
Posts:
18
Plugin Contributions:
0

Re: Customer Last Name

It's hosted locally for now, as the project is all of about 7 hours old!

Could that be an issue? Maybe the session needed refreshing? Although I didn't add that line 87, it was there by default, so the lastname should already be called, right?

16 Dec 2011, 2:44 AM
#13
goldfox avatar

goldfox

New Zenner

Join Date:
Dec 2011
Posts:
18
Plugin Contributions:
0

Re: Customer Last Name

Well I'll be damned.

The whole "turn it off, turn it back on again" just totally worked. I logged out, and logged back in, and there is my surname in all its glory.

Bizarre. Like I said, I didn't add the last_name call, so it should have already been in SESSION data, but hey. It's there now.

Sorry to waste your time!! But thank you so much!

-Chris

16 Dec 2011, 2:44 AM
#14
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Customer Last Name

No idea ... I don't have your site to test ... only you do ...

Have you tried for additional giggles to create a new account?

Are you sure that the code you are testing has the right code in it?