【发布时间】:2020-06-17 17:35:08
【问题描述】:
我一直在使用 Opencart 开发一个模块,我想知道如何获取当前用户信息。
我在想这样的事情:$this->getuserid();
【问题讨论】:
标签: opencart
我一直在使用 Opencart 开发一个模块,我想知道如何获取当前用户信息。
我在想这样的事情:$this->getuserid();
【问题讨论】:
标签: opencart
我刚刚发现:
$this->customer->getFirstName();
$this->customer->getLastName();
$this->customer->getEmail();
$this->customer->getTelephone();
$this->customer->getFax();
等等。
源代码(包括其他可用方法)位于system/library/customer.php 文件中。
您可以在任何地方使用这些方法。
希望这会有所帮助。
【讨论】:
客户和用户之间是有区别的。要获取当前用户 ID(管理员、经理等),请执行以下操作:
$this->session->data['user_id'];
【讨论】:
另一种获取当前登录用户id的方法
$this->user->getId();
【讨论】:
在 oc3 中
可以在
中获取library文件夹your_project/system/library/cart/customer.php
在customer.php 文件中,您将获得可以在控制器中调用并检查的所有函数。
$this->customer->getId();
获取您的客户 ID 等,您可以从 customer.php 文件中获取。
谢谢。
【讨论】: