Found under "app/code/core/Mage/Page/Block/Html/Header.php":
public function getWelcome()
{
if (empty($this->_data['welcome'])) {
if (Mage::app()->isInstalled() && Mage::getSingleton('customer/session')->isLoggedIn()) {
$this->_data['welcome'] = $this->__('Welcome, %s!', Mage::getSingleton('customer/session')->getCustomer()->getName());
} else {
$this->_data['welcome'] = Mage::getStoreConfig('design/header/welcome');
}
}
return $this->_data['welcome'];
}
So it looks like Mage::getSingleton('customer/session')->getCustomer()
will get your current logged in customer ;)
To get the currently logged in admin:
Mage::getSingleton('admin/session')->getUser();
Have a look at the helper class: Mage_Customer_Helper_Data
To simply get the customer name, you can write the following code:-
$customerName = Mage::helper('customer')->getCustomerName();
For more information about the customer's entity id, website id, email, etc. you can use getCustomer function. The following code shows what you can get from it:-
echo "<pre>"; print_r(Mage::helper('customer')->getCustomer()->getData()); echo "</pre>";
From the helper class, you can also get information about customer login url, register url, logout url, etc.
From the isLoggedIn function in the helper class, you can also check whether a customer is logged in or not.
You can get current login customer name from session in following way :
$customer = Mage::getSingleton('customer/session')->getCustomer();
This will return the customer details of current login customer.
Now you can get customer name by using getName()
echo $customer->getName();
for Email use this code
$email=$this->__('Welcome, %s!', Mage::getSingleton('customer/session')->getCustomer()->getEmail());
echo $email;
$customer = Mage::getSingleton('customer/session')->getCustomer(); $customerAddressId = Mage::getSingleton('customer/session')->getCustomer()->getDefaultBilling(); $address = Mage::getModel('customer/address')->load($customerAddressId); $fullname = $customer->getName(); $firstname = $customer->getFirstname(); $lastname = $customer->getLastname(); $email = $customer->getEmail(); $taxvat = $customer->getTaxvat(); $tele = $customer->getTelephone(); $telephone = $address->getTelephone(); $street = $address->getStreet(); $City = $address->getCity(); $region = $address->getRegion(); $postcode = $address->getPostcode();
Get customer Default Billing address
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With