【问题标题】:Get info about current user in Opencart在 Opencart 中获取有关当前用户的信息
【发布时间】:2020-06-17 17:35:08
【问题描述】:

我一直在使用 Opencart 开发一个模块,我想知道如何获取当前用户信息。

我在想这样的事情:$this->getuserid();

【问题讨论】:

    标签: opencart


    【解决方案1】:

    我刚刚发现:

    $this->customer->getFirstName();
    $this->customer->getLastName();
    $this->customer->getEmail();
    $this->customer->getTelephone();
    $this->customer->getFax();
    

    等等。

    源代码(包括其他可用方法)位于system/library/customer.php 文件中。

    您可以在任何地方使用这些方法。

    希望这会有所帮助。

    【讨论】:

      【解决方案2】:

      客户和用户之间是有区别的。要获取当前用户 ID(管理员、经理等),请执行以下操作:

      $this->session->data['user_id'];
      

      【讨论】:

      • 没错!我正在寻找用户,并且在很多帖子中都为客户提供了答案,这令人困惑。感谢您的帮助。
      【解决方案3】:

      另一种获取当前登录用户id的方法

      $this->user->getId();
      

      【讨论】:

        【解决方案4】:

        在 oc3 中

        可以在

        中获取library文件夹
        your_project/system/library/cart/customer.php
        

        在customer.php 文件中,您将获得可以在控制器中调用并检查的所有函数。

        $this->customer->getId();
        

        获取您的客户 ID 等,您可以从 customer.php 文件中获取。

        谢谢。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-04-06
          • 2011-08-31
          • 1970-01-01
          • 2021-06-11
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2011-03-08
          相关资源
          最近更新 更多