Magento 我如何回显用户名
我使用现代主题 我在标题上有一个livechat按钮,我想解析模板中的信息 这是livechat按钮:Magento 我如何回显用户名,magento,echo,Magento,Echo,我使用现代主题 我在标题上有一个livechat按钮,我想解析模板中的信息 这是livechat按钮: <!-- http://www.LiveZilla.net Chat Button Link Code --><a href="[removed]void(window.open('http://xxxxxx.fr/livezilla.php?code=BOUTIQUE&en=<!!CUSTOMER NAME!!>&ee=<!
<!-- http://www.LiveZilla.net Chat Button Link Code --><a href="[removed]void(window.open('http://xxxxxx.fr/livezilla.php?code=BOUTIQUE&en=<!!CUSTOMER NAME!!>&ee=<!!!CUSTOMER EMAIL!!>.........
这很正常。
与模板app/design/frontend/default/modern/template/page/html/header.phtml
对应的块位于app/code/Core/page/block/html/header.php
如果阅读该块的代码,您将看到没有名为“getCustomer()”的函数。
当您尝试调用$this->getCustomer()->getName()时在模板页面上,由于函数getCustomer()不存在,因此它不会返回任何内容
结果是,然后您将尝试在任何情况下调用'getName()'。。然后出现错误消息:致命错误:对非对象调用成员函数getFirstname()
如您所知:对非对象调用成员函数getFirstname()
如果要在header.phtml中获取客户名称,应执行以下操作:
$session = Mage::getSingleton('customer/session');
if($session->isLoggedIn()) {
$customer = $session->getCustomer();
echo $customer->getName();
echo $customer->getFirstname();
}
胡格斯
$session = Mage::getSingleton('customer/session');
if($session->isLoggedIn()) {
$customer = $session->getCustomer();
echo $customer->getName();
echo $customer->getFirstname();
}