Jump to content

Recommended Posts

(sorry for bad english )

 

For many countries the actual problem - have a different currency to the frontend (front office) and backend (back office)

For example pricing in U.S. dollars, and buyers buy goods in the national currency, it is also true when dropshipping

Also, the store owner wants the buyer immediately upon entering the store saw the price in local currency (not in the default currency from the backend)

 

Solution: need to replace the function setCurrency () of class Tools

(I quote the decision to release 1.4.6.2, if your version of this function is the opposite - make changes to yourcode)

 

go to in /overrides/classes and create new file Tools.php, edit it and paste code

<?php
class Tools extends ToolsCore
{
public static function setCurrency()
{
 global $cookie;
 if (self::isSubmit('SubmitCurrency'))
  if (isset($_POST['id_currency']) AND is_numeric($_POST['id_currency']))
  {
$currency = Currency::getCurrencyInstance((int)($_POST['id_currency']));
if (is_object($currency) AND $currency->id AND !$currency->deleted)
 $cookie->id_currency = (int)($currency->id);
  }
 if ((int)$cookie->id_currency)
 {
  $currency = Currency::getCurrencyInstance((int)$cookie->id_currency);
  if (is_object($currency) AND (int)$currency->id AND (int)$currency->deleted != 1 AND $currency->active)
return $currency;
 }
 //$currency = Currency::getCurrencyInstance((int)(Configuration::get('PS_CURRENCY_DEFAULT')));
 $currency = Currency::getCurrencyInstance((int)('4'));
 if (is_object($currency) AND $currency->id)
  $cookie->id_currency = (int)($currency->id);
 return $currency;
}
}
?>

 

In fact, changes are only one line of code

 

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

in this code line $currency = Currency::getCurrencyInstance((int)('4')); digit 4 - a currency ID has to see the buyer at the entrance to the store. ID can be found by logging into admin part (back office) of such a Payment - Currencies, in currency table - the number

 

If this code was useful for you, then press "like post", I'm curious to know how many people have the same problem as me :)

 

I am attaching a file ready

Tools.php

  • Like 8

Share this post


Link to post
Share on other sites
  • 5 weeks later...

I have a problem making that change, my clients when they arrive in the form of payment is not the option for transfer

 

I have to change in my bankwire.php to understand which is the default currency front office?

 

Help me please

 

Henry

 

 

}

 

private function _checkCurrency($cart)

{

$currency_order = new Currency(intval($cart->id_currency));

$currencies_module = $this->getCurrency();

$currency_default = Configuration::get('PS_CURRENCY_DEFAULT');

 

if (is_array($currencies_module))

foreach ($currencies_module AS $currency_module)

if ($currency_order->id == $currency_module['id_currency'])

return true;

}

Share this post


Link to post
Share on other sites

How I do to change that in in you see of $currency_default = Configuration::get('PS_CURRENCY_DEFAULT'); to $currency_default = Configuration::get('CURRENCY FRONT OFFICE') In a correct way

 

Thant you Sergey

Share this post


Link to post
Share on other sites
  • 1 month later...
  • 1 month later...
  • 11 months later...
  • 1 year later...
  • 2 years later...

You can buy an extension for PrestaShop or you can do it yourself, fix just two lines of code.


So, open the file /classes/tools.php and find this (twice):


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


 


And replace it to


Currency::getCurrencyInstance(N);


 


where N is an id of currency (1, 2, 3 etc.).


That's all. Don't forget to save the file. Tested with PrestaShop 1.6.


Share this post


Link to post
Share on other sites
  • 8 months later...
On 07. 05. 2017. at 10:30 AM, cosmoll said:

You can buy an extension for PrestaShop or you can do it yourself, fix just two lines of code.

 

So, open the file /classes/tools.php and find this (twice):

 

 

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

 

 

 

 

 

And replace it to

 

 

Currency::getCurrencyInstance(N);

 

 

 

 

 

where N is an id of currency (1, 2, 3 etc.).

 

 

That's all. Don't forget to save the file. Tested with PrestaShop 1.6.

 

Hello. After i have done this my site doesnt want to load any more. My site is topprodaja.eu

 

I am getting following erorr message:

Fatal error: Class 'Tools' not found in /home/topproda/public_html/config/config.inc.php on line 81

Share this post


Link to post
Share on other sites
  • 9 months later...
  • 2 years later...
Posted (edited)
On 10/25/2018 at 11:50 PM, El Patron said:

here is module, no need for hacking to support different front office currency than shop default currency

https://www.prestaheroes.com/en-us/modules/front-office-default-currency

I have paid for this module, unfortunately doesn't work if somebody browse the shop from incognito mode ( which most of people do these days ) . Still goes on BO default currency. 

Edited by Zeryk (see edit history)

Share this post


Link to post
Share on other sites
3 hours ago, Zeryk said:

I have paid for this module, unfortunately doesn't work if somebody browse the shop from incognito mode ( which most of people do these days ) . Still goes on BO default currency. 

Hello, my module work also in incognito mode you can chceck 

https://addons.prestashop.com/en/international-localization/45953-default-front-office-currency.html

 

Share this post


Link to post
Share on other sites
Posted (edited)
On 4/4/2021 at 6:30 PM, fancy|modules said:

Hello, my module work also in incognito mode you can chceck 

https://addons.prestashop.com/en/international-localization/45953-default-front-office-currency.html

 

the prices on your products in BO are in euros and so the prices in FO , there is only 1 currency.

I need to see an option of few different currencies in shop from which can choose 1 as default in BO prices and then can switch a different currency for FO prices. 

So I have to be able to access in menu - Localization , where can download / install new pack with whatever currency ( country ) I choose and set it as a default for shop. Then go up to your module and choose from any currency I have installed into the shop and use it as FO currency ( which will be different from BO )

I have PS 1.6

I use 2 currencies where Currency 1  is set prices as default in back office for pricing my products and Currency 2  ( U$ ) is as a secondary one which visitor has to switch the button for shopping in U$. My point is that I want to keep my original currency as default in BO but when any visitor from any country trough any browser visit my site , it will show the Currency 2 ( U$ ) first with option to switch it back to Currency 1. 

I used override tools.php for that ( coz paid module not working  ) to set FO default by ISO USD , it works on all browsers , even Mozilla incognito , but not on Chrome in guest mode for some reason. 

You can keep me posted in PM if convenient.

Thank you!

 

 

Edited by Zeryk (see edit history)

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