gpt4 book ai didi

php - opencart 将额外字段添加到帐户

转载 作者:行者123 更新时间:2023-11-30 00:39:20 25 4
gpt4 key购买 nike

我刚刚在表 customer 中创建了一行。我有一个在那里写入信息的模块。它工作正常,但我无法在模板中显示此字段,这是我所做的更改:目录/模型/帐户/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 JOIN " . DB_PREFIX . "customer_group cg ON (c.customer_group_id = cg.customer_group_id) ";

目录/view/template/default/ommon/header.php

<?php echo $competition_rate; ?>

catalog/controller/common/header.php

$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'));

我得到以下内容

Fatal error: Call to undefined method Customer::getcompetition_rate() in C:\xampp\htdocs\sport\catalog\controller\common\header.php on line 76

我错过了什么?请帮忙!该行信息可以通过PhpMyadmin查看

最佳答案

您必须编辑核心文件system/library/customer.php,并在登录时将此字段添加到SELECT部分,然后创建一个新的getter 方法来检索此属性。

例如:

  1. private $address_id; 之后添加 private $competition_rate;
  2. $this->address_id = $customer_query->row['address_id']; 之后添加 $this->address_id = $customer_query->row['competition_rate'];/
  3. 创建新方法public function getCompetitionRate() { return $this->competition_rate; }

现在您可以在 header 中调用 $this->customer->getCompetitionRate() 方法。

关于php - opencart 将额外字段添加到帐户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21906304/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com