我正在尝试在付款方式和运输方式控制器中调用客户组ID。
我正在使用以下代码:
//groupId
$this->load->language('account/account');
if ($this->customer->isLogged()) {
$data['groupId'] = $this->customer->getGroupId();
} elseif ($this->config->get('config_customer_group_id')) {
$data['groupId'] = $this->config->get('config_customer_group_id');
}
在模板中这样调用时:
<p>GroupID: <?php echo (int)$groupId ?></p>
返回为:
GroupID:0
当预期的groupID为4时。
已登录的用户被分配给ID为4的组。
我要尝试做的是使特定客户组需要附加注释字段。
答案 0 :(得分:1)
您可以使用以下代码
if ($this->customer->isLogged()) {
$data['groupId'] = $data['groupId'] = $this->customer->getGroupId();
} elseif (isset($this->config->get('config_customer_group_id'))) {
$data['groupId'] = $this->config->get('config_customer_group_id');
} else {
$data['groupId'] = 0;
}
在模板中这样调用时:
<p>GroupID: <?php echo $groupId ?></p>
返回为:您的客户组ID
已登录的用户将分配给具有所需ID的组。
我认为上面的代码有效。.