问题描述
我使用的是 opencart V 3.0.3.0
我想检查客户组 ID 是否为默认值,然后向他展示更改密码表单并允许更改密码。否则在我的网站上显示带有其他平台链接的表格以更改密码。
包含指向其他平台的密码更改链接的表格由我完成,并且按预期在更改密码页面上可见。
但是我不知道如何检查客户组 ID 并显示表单以更改密码? catalog/controller
和 catalog/model
中的哪些文件需要更改,哪些可以在 password.twig
例如password.twig
{{ if customer_group_id==1}} // 1 = default
code to show change password form
{{ else }}
show my created table with links to other platforms on my website.. (it is done and working as expected right Now )
{{ end if }}
解决方法
所以经过一番搜索,我成功了。
为可能需要它的其他人提供解决方案
在catalog/controller/account/password.php中添加
if ($this->customer->isLogged()) {
$data['customer_group_id'] = $this->customer->getGroupId();
} elseif ($this->config->get('config_customer_group_id')) {
$data['customer_group_id'] = $this->config->get('config_customer_group_id');
}
在第 12 行之后,即
$this->load->language('account/password');
在目录/视图/主题/默认/模板/帐户/密码.twig
添加
{% if (customer_group_id=='1') %}
// Your needed code
{% else %}
// another needed code
{% endif %}
之后
<h1>{{ heading_title }}</h1>