Magento 2 login customer details – how to get Magento 2 login customer details
In this pot we will show you how to Magento 2 login customer details. we will give you code for login customer details using Magento 2 and method for get detil of Full Name, First Name, Last Name and Email Address.
add this this following code and remove comment and you will get all Magento 2 login customer details and if you remove of print_r($customer_session->getCustomer());
and wyou will get Magento 2 login customer details.
get('Magento\Customer\Model\Session'); if($customer_session->isLoggedIn()) { /* // for get all detail of customer echo ""; print_r($customer_session->getCustomer()); echo "";
*/
echo "
".$customer_session->getCustomer()->getId();
// get Id of Customer
echo "
".$customer_session->getCustomer()->getName()";
// get Full Name of Customer
echo "
".$customer_session->getCustomer()->getEmail()";
// get Email Name of Customer
echo "
".$customer_session->getCustomer()->getGroupId()";
// get Customer Group Id of Customer
/*
* reove comment for other information
*/
// $customer_session->getCustomer()->getStoreId(); // Store Id
// $customer_session->getCustomer()->getCreatedAt(); // Created At
// $customer_session->getCustomer()->getUpdatedAt(); // Updated At
// $customer_session->getCustomer()->getIsActive(); // Is Active
// $customer_session->getCustomer()->getDisableAutoGroupChange();
// $customer_session->getCustomer()->getTaxvat();
// $customer_session->getCustomer()->getPasswordHash();
// $customer_session->getCustomer()->getCreatedIn(); // Created In
// $customer_session->getCustomer()->getGender(); //
// $customer_session->getCustomer()->getDefaultBilling(); // ID
// $customer_session->getCustomer()->getDefaultShipping(); // ID
// $customer_session->getCustomer()->getDob(); // yDob
// $customer_session->getCustomer()->getTaxClassId(); // ID
}
else
{
echo "customer is not logged In!!!";
}
?>You also like Get Order Details using Order and customer registration programmatically and Magento2 admin login user detail and Magento 2 Featured products