Php opencart将外部字段添加到帐户
我刚刚在customer表中创建了一行。我有一个模块在那里写信息。它工作正常,但我无法在模板中显示此字段。我更改了以下内容: catalog/model/account/customer.phpPhp opencart将外部字段添加到帐户,php,mysql,opencart,Php,Mysql,Opencart,我刚刚在customer表中创建了一行。我有一个模块在那里写信息。它工作正常,但我无法在模板中显示此字段。我更改了以下内容: catalog/model/account/customer.php $sql = "SELECT *, CONCAT(c.firstname, ' ', c.lastname,' ',c.competition_rate,c) AS name, cg.name AS customer_group FROM " . DB_PREFIX . "customer c LEFT
$sql = "SELECT *, CONCAT(c.firstname, ' ', c.lastname,' ',c.competition_rate,c) AS name, cg.name AS customer_group FROM " . DB_PREFIX . "customer c LEFT JOIN " . DB_PREFIX . "customer_group cg ON (c.customer_group_id = cg.customer_group_id) ";
catalog/view/template/default/ommon/header.php
<?php echo $competition_rate; ?>
$this->data['text_logged'] = sprintf($this->language->get('text_logged'), $this->url->link('account/account', '', 'SSL'), $this->customer->getFirstName(),$this->customer->getcompetition_rate(), $this->url->link('account/logout', '', 'SSL'));
我得到以下信息
致命错误:在第76行的C:\xampp\htdocs\sport\catalog\controller\common\header.php中调用未定义的方法Customer::getcompetition\u rate()
我错过了什么?请帮忙!这一行的信息可以通过PhpMyadmin获得,您必须编辑核心文件
system/library/customer.php
,并在登录时将此字段添加到SELECT
部分,然后创建一个新的getter方法来检索此属性
例如:
private$competition\u费率代码>在私有$address\u id之后代码>
$this->address\u id=$customer\u query->row['competition\u rate'代码>在$this->address\u id=$customer\u query->row['address\u id']之后代码>
公共函数getCompetitionRate(){return$this->competition\u rate;}
现在,您可以在标题中调用
$this->customer->getCompetitionRate()
方法。客户模型或控制器中没有的getcompetition\u rate()函数仍然不起作用。错误未出现,但信息未回显。再次抱歉。我只是用一种错误的方式调用了这个方法。