Call-back icon  Sales: Call 877.832.5289 (N America)|310.295.4144 (International)

Magento

eCommerce Software for Online Growth

Magento Forum

   
Customer first name only in welcome message? 
 
Josh
Jr. Member
 
Total Posts:  5
Joined:  2007-12-07
 

I would like to display the customer’s first name only in the welcome message created when $this->getWelcome() is called.  Example: ‘Welcome, Jon!’ instead of ‘Welcome, Jon Smith!’
I did some searching on this site and in the core files of Magento and I was unable to determine the method that needs to be called or parameter that needs to be given to just return the first name of a customer for the given session.  Any help with this question is much appreciated.

Also, is there any documentation available for the general core Magento API?  If not, is there any plan in place to make them available in the future?

Thank you,
Josh

 
Magento Community Magento Community
Magento Community
Magento Community
 
Xiano
Jr. Member
 
Total Posts:  20
Joined:  2008-02-25
 

My first ever answer to a question smile

You need to go to:
app/code/core/mage/page/block/html/header.php

The code that generates the message is on line 62:

$this->_data['welcome'$this->__('Welcome, %s!'Mage::getSingleton('customer/session')->getCustomer()->getName());

Change getName to getFirstname

 
Magento Community Magento Community
Magento Community
Magento Community
 
Josh
Jr. Member
 
Total Posts:  5
Joined:  2007-12-07
 

Thanks for the snippet of code.  Worked like a charm.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Moshe
Magento Team
 
Avatar
Total Posts:  1771
Joined:  2007-08-07
Los Angeles
 

I’d like to note that all the variables provided by blocks core code are optional, and this could be achieved without changing core files by embedding this code directly in the template instead of reference to block’s provided variable:

<?php echo $this->__('Welcome, %s!'Mage::getSingleton('customer/session')->getCustomer()->getFirstName()); ?>

 Signature 

- I would love to change the world, but they won’t give me the source code -

 
Magento Community Magento Community
Magento Community
Magento Community
 
njwood60
Jr. Member
 
Total Posts:  8
Joined:  2008-09-16
 

Thanks Moshe

That’s really useful info.

Just a small typo:

getFirstName in your code should be getFirstname

Then it all works perfectly.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
 
Sales: Call 877.832.5289 (North America) 310.295.4144 (International)
© Copyright 2008 Varien. Magento, eCommerce software, is a trademark of Irubin Consulting Inc. DBA Varien
Privacy Policy|Terms of Service
Magento Community Count
52311 users|454 users currently online|105635 forum posts