Jump to content

Load a currency by default other than the default currency?


Recommended Posts

Hi guys,

 

I'm hoping that someone might be able to help me with this one, if at all possible.

My shop's default currency is USD (I need it to be in USD) and my main target market is from South Africa so most visitors require ZAR currency which is set up and configured. What I'd like to achieve without having to use a module for this purpose is for the website to automatically load ZAR currency for first-time visitors even though the default currency is USD and not ZAR. Is this possible by maybe changing some code?

 

Customers that do not require ZAR currency can of course change the currency to USD if they prefer, that option remains available via the currency selector.

 

The reason why I'd prefer not using a module for this purpose is that I have tried this before with 3 modules form the addon store and either they don't work correctly or end up slowing down the website when loading it for the first time for a new cuso5tmer. I need the website to quickly load ZAR currency by default even though the actual default currency set in Prestashop is USD.

 

Please tell me this is possible?

 

Thanks!

Edited by Claudio (see edit history)

Share this post


Link to post
Share on other sites

Hello Claudio.

 

while I can't tell you how to set ZAR as preferred currency in front office, I can tell you how to Force ZAR as your only currency in front office while having USD in back office.

**please make a backup before making any changes**
In this file , classes/Tools.php, search and edit the following lines and before we begin, please take note of your current ZAR currency ID found in the database under PREFIX_currency (example ps_currency) inside id_currency and if it differs from the one I've written below, which is 2, please change the number 2 to your ZAR currency ID:

From:

            $currency = Currency::getCurrencyInstance((int)$id_currency);	

To;

            $currency = Currency::getCurrencyInstance((int)$id_currency=2);

 

 

From:

            $currency = Currency::getCurrencyInstance((int)$cookie->id_currency);	

To:

            $currency = Currency::getCurrencyInstance(2);

 

 

From:

            $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));	

To:

            $currency = Currency::getCurrencyInstance(Configuration::get('id_currency'));

 

 

From:

                return Currency::getCurrencyInstance((int)$cookie->id_currency);	

To:

                return Currency::getCurrencyInstance(2);

 

Save and refresh your homepage.

the only problem with this solution is that is forces ZAR to be the default currency in your front office and your customers can not change it to USD, even though it might show in the currency block that USD is avaliable. Back office is unaffected though. I use this code to force SEK in my front office while having EUR in backoffice because my supplier provides me with euro prices and my customers buy in SEK.

 

 

Im working on another solution which loads the page with the preferred currency and writes it to  a cookie file but I have not figured out yet how to do it.

I will come back when I do, until then, have a great time.

 

Edited by rozhawni (see edit history)

Share this post


Link to post
Share on other sites
  • 2 years later...
On 10/1/2018 at 10:36 PM, Claudio said:

Anyone?

 

I myself need this as well. My product supplier gives me rate of products in foreign currency. So, i want to add my price in that currency so that i do not have to change the final price if the currency conversion rate changes and it actually changes very often. And, it gets tougher to deal with the situation with the growing of your store. 

 

Have you managed any solution so far? Other than buying any module. Buying a module is okay. But, not a viable option of a new store or a store that doesn’t make much revenue out of it. 

Share this post


Link to post
Share on other sites
  • 2 weeks later...
On 2/24/2021 at 1:59 PM, num47 said:

I myself need this as well. My product supplier gives me rate of products in foreign currency. So, i want to add my price in that currency so that i do not have to change the final price if the currency conversion rate changes and it actually changes very often. And, it gets tougher to deal with the situation with the growing of your store. 

 

Have you managed any solution so far? Other than buying any module. Buying a module is okay. But, not a viable option of a new store or a store that doesn’t make much revenue out of it. 

Do you not read these post?  You just ask same question?  It was solved with my post.  If you cannot afford there is always gofundme.

Share this post


Link to post
Share on other sites
  • 2 weeks later...
On 10/6/2018 at 3:46 PM, rozhawni said:

Hello Claudio.

 

while I can't tell you how to set ZAR as preferred currency in front office, I can tell you how to Force ZAR as your only currency in front office while having USD in back office.

**please make a backup before making any changes**
In this file , classes/Tools.php, search and edit the following lines and before we begin, please take note of your current ZAR currency ID found in the database under PREFIX_currency (example ps_currency) inside id_currency and if it differs from the one I've written below, which is 2, please change the number 2 to your ZAR currency ID:

From:


            $currency = Currency::getCurrencyInstance((int)$id_currency);	

To;


            $currency = Currency::getCurrencyInstance((int)$id_currency=2);

 

 

From:


            $currency = Currency::getCurrencyInstance((int)$cookie->id_currency);	

To:


            $currency = Currency::getCurrencyInstance(2);

 

 

From:


            $currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));	

To:


            $currency = Currency::getCurrencyInstance(Configuration::get('id_currency'));

 

 

From:


                return Currency::getCurrencyInstance((int)$cookie->id_currency);	

To:


                return Currency::getCurrencyInstance(2);

 

Save and refresh your homepage.

the only problem with this solution is that is forces ZAR to be the default currency in your front office and your customers can not change it to USD, even though it might show in the currency block that USD is avaliable. Back office is unaffected though. I use this code to force SEK in my front office while having EUR in backoffice because my supplier provides me with euro prices and my customers buy in SEK.

 

 

Im working on another solution which loads the page with the preferred currency and writes it to  a cookie file but I have not figured out yet how to do it.

I will come back when I do, until then, have a great time.

 

Hello,

does this work also for the multistore? I need to show only one currency different from default currency in one of the shops.

 

Thank you very much   Michal

Share this post


Link to post
Share on other sites

If anyone needs a solution to this problem and is willing to pay a small fee for a developer to implement the solution which is what I ended up having to do, then feel free to try this developer that I found on Freelancer which I used for this and some other mods. I can personally highly recommend their services;

https://www.freelancer.com/u/technovation1?ref_project_id=17876202

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More