Get info about current user in Opencart
Asked Answered
R

4

10

I have been work on a module with Opencart and I was wondering how I can get current user information.

I was thinking something like this: $this->getuserid();

Retro answered 30/10, 2012 at 6:52 Comment(0)
R
24

I just found it out:

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

and so on.

The source code (including the other methods available) is located in the system/library/customer.php file.

You can use the methods just anywhere.

Hope this helps.

Retro answered 30/10, 2012 at 6:54 Comment(0)
H
9

There is difference between customer and user. To get current user ID (admin, manager etc) do the following:

$this->session->data['user_id'];
Heid answered 19/2, 2015 at 1:17 Comment(1)
Exactly! I was searching for user and the answers have been for customer in so many posts, it's confusing. Thanks for the help.Commander
C
1

Another way to get the id of the user that is currently logged in

$this->user->getId();
Commander answered 22/11, 2017 at 6:2 Comment(0)
D
0

In oc3

You can get the library folder in

your_project/system/library/cart/customer.php

In the customer.php file, you will get all the functions where you can call in your controller and check it out.

$this->customer->getId();

Get your customer id and etc etc you can get it from the customer.php file.

Thanks.

Dacosta answered 17/6, 2020 at 9:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.