I do not want to store cookie in the browser for language in opencart 3.x
Previously on Opencart 2.x was made some modification in system/librabry/session.php,
but in Opencart 3.x is different and cannot do it.
My problem comes from that my main page is onepage with only link to several stores in different languages but that main page is set to english and when click on some other store get the language from the default store not the language itself:
mytore.com -> English
gr.mystore.com -> Greek
ro.mystore.com -> Romanian
...
When the clients visit mystore.com they see only the logo of the store and several options for countries that we work and want when client click on the country that want to open that store in the language set in the admin panel, for gr.mystore.com to be Greek.
But when visit at first place mystore.com the browser save cookie with language content EN and then all other sub stores open in that language.
What I'm try till now:
Just modify two files to not store in database any sessions and in the file:
system/library/session/db.php
and
system/library/session/file.php
but still save that cookies.
Maybe will help if make only language cookie to be expire in less then 1 sec or just make to not store that cookie!?
Please if someone can help I'll very happy
Previously on Opencart 2.x was made some modification in system/librabry/session.php,
but in Opencart 3.x is different and cannot do it.
My problem comes from that my main page is onepage with only link to several stores in different languages but that main page is set to english and when click on some other store get the language from the default store not the language itself:
mytore.com -> English
gr.mystore.com -> Greek
ro.mystore.com -> Romanian
...
When the clients visit mystore.com they see only the logo of the store and several options for countries that we work and want when client click on the country that want to open that store in the language set in the admin panel, for gr.mystore.com to be Greek.
But when visit at first place mystore.com the browser save cookie with language content EN and then all other sub stores open in that language.
What I'm try till now:
Just modify two files to not store in database any sessions and in the file:
system/library/session/db.php
and
system/library/session/file.php
but still save that cookies.
Maybe will help if make only language cookie to be expire in less then 1 sec or just make to not store that cookie!?
Please if someone can help I'll very happy
Last edited by Reshovski on Thu Nov 30, 2017 7:01 pm, edited 1 time in total.
catalog/controller/startup/startup.php file:
Code: Select all
if (!isset($this->session->data['language']) || $this->session->data['language'] != $code) {
$this->session->data['language'] = $code;
}
if (!isset($this->request->cookie['language']) || $this->request->cookie['language'] != $code) {
setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Thanks a lot, exactly what I search for.straightlight wrote: ↑Wed Nov 29, 2017 9:42 pmcatalog/controller/startup/startup.php file:
Code: Select all
if (!isset($this->session->data['language']) || $this->session->data['language'] != $code) { $this->session->data['language'] = $code; } if (!isset($this->request->cookie['language']) || $this->request->cookie['language'] != $code) { setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']); }
For more information to other people need that, just comment some rows:
in catalog/controller/startup/startup.php file:
line 97: $this->session->data['language'] = $code;
line 101: setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $this->request->server['HTTP_HOST']);
in catalog/controller/common/language.php file:
line 8: $data['code'] = $this->session->data['language'];
Hi Reshovski,
I did comment the code you refer but still the site opens in English!
How to force it to open in default language which is not EN?
Thank you!
I did comment the code you refer but still the site opens in English!
How to force it to open in default language which is not EN?
Thank you!
Pottery Glaze shop
The default language in the OC admin must be switched to your preferred language from your admin - > systems - > localisation - > languages form.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dear straightlight,
Of course I did set Default language other than English but site still opens in English on first load.
This is a serious bug and I already one year trying to solve this issue.
Please help!
Of course I did set Default language other than English but site still opens in English on first load.
This is a serious bug and I already one year trying to solve this issue.
Please help!
Pottery Glaze shop
If you believe this issue to be a serious bug, try the alpha version (3.1.0.0a from Github) on a separate folder and new database noticing if the issue persists.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
After opening a ticket in OC support they provide a solution!
in catalog/controller/startup/startup.php
Find
and just comment it!
Also works in OC 2.3
Enjoy!
in catalog/controller/startup/startup.php
Find
Code: Select all
$code = $detect ? $detect : '';
Also works in OC 2.3
Enjoy!
Pottery Glaze shop
The reason why this code would be commented out at this point is because the browser code does not correspond with your language pack ...
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: No registered users and 21 guests