Page 1 of 1

Store language - where is it stored?

Posted: Fri Feb 03, 2023 1:32 am
by scottyboyyy
I'm trying to access what the default language set to a store within Stores - Settings - local (tab) - language, here it can be set to any language but I can't find how to access it or where it is stored in the database.

This just gets the current language:

Code: Select all

(int)$this->config->get('config_language_id');
But I want to access the language it is set to within admin settings.

Anyone know? :D

Thanks!

opencart 3.0.1.2

Re: Store language - where is it stored?

Posted: Fri Feb 03, 2023 12:25 pm
by TMD Extension @
get the current language from the session
$this->session->data['language']

from the database get the list of languages
$this->config->get('config_language')

or just print the current language code
echo $this->language->get('code')

You can use all these codes to get the language of the OpenCart Store

Re: Store language - where is it stored?

Posted: Fri Feb 03, 2023 9:11 pm
by by mona
Yes the above and to add to that ..

Code: Select all

$this->model_localisation_language->getLanguages();
gets all the languages you support in an array

Code: Select all

$this->request->cookie['language'];
gets the language code from the client cookie (if set)

Code: Select all

$this->config->get('config_language_id');
gets the current language id

Code: Select all

$this->session->data['language'];
gets the current language code (if set)

Code: Select all

$this->config->get('config_language');
gets your store's default language code (as set in admin)

All of these are used in the language part of catalog/controller/startup/startup.php
on every request, in order:
1) use the language stored in the session if present
2) otherwise use the language stored in the cookie if present
3) otherwise use the language set in the client language-accept header if present and supported
4) otherwise use the default language as set in admin
5) store the language code in the session and the language id in config