문제

How can I display customer name in the header after logged in successfully?

도움이 되었습니까?

해결책

Go to your current theme and your current header, some themes uses different headers : app/design/frontend/default/themek/te‌​mplate/page/html/hea‌​der.phtml for exemple then add this:

<?php if ( Mage::getSingleton('customer/session')->isLoggedIn() ): ?>
    <div class="customer-name">    
        <?php echo Mage::getSingleton('customer/session')->getCustomer()->getName(); ?>
    </div> 
<?php endif; ?>

다른 팁

Try this:

EDIT: file location: app/design/frontend/your_package/your_theme/template/page/html/header.phtml

Add these in this file where you want to get the name to be shown.

<?php if (Mage::getSingleton('customer/session')->isLoggedIn()): ?>

<?php echo Mage::getSingleton('customer/session')->getCustomer()->getName() ?>

<?php endif; ?>

When the customer is logged in, you can get customer session in frontend from any phtml file.

To show customer name in header, you would need to open header.phtml file located at:

app/design/frontend/yourpackage/yourtheme/template/page/html/

folder and write below code where you want to display current logged in customer name:

<?php
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
echo Mage::getSingleton('customer/session')->getCustomer()->getName();
}
?>

Please let me know if you find any problem.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top