在header.php
中添加:$data['customer_firstname'] = $this->customer->getFirstName();
你可能是什么:
<?php
class ControllerCommonHeader extends Controller {
public function index() {
$data['customer_firstname'] = $this->customer->getFirstName();
显示名称,例如在header.tpl:<?php echo $customer_firstname ?>
中
登录到您的商店经理:转到扩展、修改和升级(右上角按钮)。
准备好了!
OpenCart项目中有两个header.tpl文件。我认为您正在public_html/controller/common/header.tpl中编辑header.tpl,因此无法解决您编辑此文件的问题。
转到第二个header.tpl文件所在的另一个位置。你可以在publichtml/system/storage/modification/controller/common/header.tpl中找到它。在那里你可以通过添加这些值来获得值,
$data['customer_firstname'] = $this->customer->getFirstName();
$data['customer_lastname'] = $this->customer->getLastName();
这将解决你的问题。
试试这个:
获取客户信息:
<?php
class ControllerCommonHeader extends Controller {
public function index() {
$customer_info = $this->model_account_customer->getCustomer($this->customer->getId());
$data['customer_firstname'] = $customer_info['firstname'];
引用的帖子使用
$data['customer_firstname']
您应该将变量放在$data数组中,以便将其传递给模板。。。
在header.php
中添加:$data['customer_firstname'] = $this->customer->getFirstName();
你可能是什么:
<?php
class ControllerCommonHeader extends Controller {
public function index() {
$data['customer_firstname'] = $this->customer->getFirstName();
显示名称,例如header.tpl
:<?php echo $customer_firstname ?>
登录到您的商店经理:转到扩展、修改和升级(右上角按钮)。
准备好了!