Page 1 of 1

[SOLVED] how to remove currency cookie if store has only 1 currency?

Posted: Mon Feb 25, 2019 10:30 pm
by radi8tor
Hi,

Is there a way to remove/disable currency cookie in Opencart because my store has only 1 currency and this is obsolete?

Thanks!

OC version: 3.0.2.0
Theme made by: Zemez.io

Re: how to remove currency cookie if store has only 1 currency?

Posted: Mon Feb 25, 2019 11:22 pm
by straightlight
Not sure what you mean by obsolete but it shouldn't do any difference whether it's one currency or multiple currencies being tracked on a store …

In your catalog/controller/startup/startup.php file,

find:

Code: Select all

if (!isset($this->request->cookie['currency']) || $this->request->cookie['currency'] != $code) {
replace with:

Code: Select all

if (!isset($this->request->cookie['currency']) || (($this->request->cookie['currency'] != $code) && sizeof($currencies) > 1)) {
This should provide what you need but I don't see the purpose on this one.

Re: how to remove currency cookie if store has only 1 currency?

Posted: Tue Feb 26, 2019 7:02 pm
by paulfeakins
radi8tor wrote:
Mon Feb 25, 2019 10:30 pm
Is there a way to remove/disable currency cookie in Opencart
Why?

Re: how to remove currency cookie if store has only 1 currency?

Posted: Tue Feb 26, 2019 9:47 pm
by Johnathan
I just want to add in that some parts of OpenCart --- and certainly some extensions --- rely on that cookie, so removing it may cause you issues. You're safer to just leave it alone, but if it matters to you a lot, straightlight's edit should work to make sure it's not set when first loading the store.

Re: how to remove currency cookie if store has only 1 currency?

Posted: Fri Mar 01, 2019 1:33 am
by radi8tor
Thanks everybody for your input on this. I will consider not to remove the currency cookie.

Re: [SOLVED] how to remove currency cookie if store has only 1 currency?

Posted: Sat Feb 15, 2020 12:35 am
by webtrekker
I,too, find this currency cookie annoying. I have my default currency set to GBP but it always displays USD in my shop. Most posts I've read suggest deleting the cookie and then it will reset itself when the site is loaded again. That's fine, but ........................ the latest versions of Firefox don't allow you to delete a single cookie, the only option available is to delete ALL cookies for that domain, which means a lot of time wasted logging back into non-OpenCart related parts of your site.

Re: [SOLVED] how to remove currency cookie if store has only 1 currency?

Posted: Sat Feb 15, 2020 1:27 pm
by letxobnav
currency is set just like language in order:

language:
1) if it it set in the session
2) if it is set in the cookie
3) language based on browser accept, if you support those languages
4) your default language


currency:
1) if it it set in the session
2) if it is set in the cookie
3) your default currency

when changing language or currencies, it is set in the session and the cookie.

if your browser displays USD while your default currency is GBP, then you have set that USD currency when last visiting your site as that would be in the cookie.
or you have some extension which changes the default currency based on language or ip.