在用户登录opencart 3.0模板后,在顶部标题和我的帐户下拉列表中显示用户名

时间:2017-10-04 04:19:44

标签: twig opencart-3

我正在研究catalog/theme/customtemplate/template/header/header1.twig

也在catalog/controller/acount/account.php

但我无法获得输出。那么我必须添加什么文件?

2 个答案:

答案 0 :(得分:1)

catalog/controller/common/header.php中为客户优先添加以下代码&姓氏。

$data['customer_firstname'] = $this->customer->getFirstName();
$data['customer_lastname'] = $this->customer->getLastName();

catalog/view/theme/your-theme/template/common/header.twig&然后为名字和姓氏添加以下代码。

{{ customer_firstname }}
{{ customer_lastname }}

请在更改后刷新开发人员缓存&然后检查一下。有关详细信息,请参阅此处刷新缓存 - https://github.com/reactjs/redux/issues/776

答案 1 :(得分:1)

如果您首先检查客户是否已登录,那会更好。 如果客户未登录,代码可能会返回错误。

if ($this->customer->isLogged()) {
   $data['customer_firstname'] = $this->customer->getFirstName();
   $data['customer_lastname'] = $this->customer->getLastName();
   }