2

我正在尝试在一个页面上调用客户的名字。该页面已仅限于登录会员。因此,如果您尝试访问该页面但尚未登录,您将被重定向到登录页面。

如何在一个特定的 CMS 页面上呼叫、回显或显示已登录客户的名字?

我是一个试图学习magento的菜鸟。非常感谢任何帮助。

4

2 回答 2

5

Magento 客户 名字 登录 用户

$session = Mage::getSingleton('customer/session');

if($session->isLoggedIn())
{
    $customer = $session->getCustomer();
    echo $customer->getFirstname();
}

尝试实现上述代码以显示您的 CMS 页面的客户名。

于 2012-10-03T05:58:23.780 回答
2

在 .phtml 文件中获取客户名称

   echo Mage::helper('customer')->getCustomerName();

阅读更多@ Magento 的当前用户?

要在 cms 页面中获取客户名称,我会使用 cms 页面调用 phtml 文件

 {{block type="core/template" template="path/to/file/customer_name.phtml"}}

阅读更多@如何在 CMS 页面 Magento 中调用 PHTML 文件

于 2012-10-03T02:11:26.670 回答