Hampelinen Hampelinen - 11 months ago 47
PHP Question

How can i fetch currently selected language opencart?

I created a custom page in Open Cart and I'm kind of pulling my hair out here. What I want to do is simple: Fetch the currently selected language(possibly from the header?). I am using Opencart version 2.0.x. I am new to php and it's not my system so I'm having a really hard time figuring this out. I have tried the following code:

$lang = $this->language->get('code');

and it returns nothing. Would really appreciate the help!

Answer Source

Both these codes returns my language code, en:

echo $this->language->get('code');
echo $this->session->data['language'];