Jump to content
  • 0
popahollic

[Solved] Different currency in Front Office and Back Office

Question

i have 2 currency, dollar & rupiah .. i want input the price in the admin (BO) with dollar ,, and appears in the website (FO) with Rupiah .. of course, after automatically converted ..

anyone can tell me the way to do that .. ?? :)

*thanks before for the answer .. :)

Share this post


Link to post
Share on other sites

41 answers to this question

Recommended Posts

  • 0

You can set the default currency on the Payment > Currencies tab to "Dollar", then enter the currency rate of "Dollar" to 1 and the currency rate of "Rupiah" to the appropriate multipler. You can then enter the prices in the Back Office in "Dollar" and customers will be able to see the prices in either "Dollar" or "Rupiah" on your website.

Share this post


Link to post
Share on other sites
  • 0
You can set the default currency on the Payment > Currencies tab to "Dollar", then enter the currency rate of "Dollar" to 1 and the currency rate of "Rupiah" to the appropriate multipler. You can then enter the prices in the Back Office in "Dollar" and customers will be able to see the prices in either "Dollar" or "Rupiah" on your website.


i don't want to use 2 option of currency in Front Office ($ | Rp)("Dollar" or "Rupiah") .. but , i want to automattically only use Rupiah in front office ..

Share this post


Link to post
Share on other sites
  • 0

Then uninstall the "Currency block" and change line 22 of init.php from:

$cookie = new Cookie('ps');



$cookie = new Cookie('ps');
$cookie->id_currency = 2;



Change 2 to the ID of the currency you want to be used in the Front Office. This will force the currency to 2 whenever a customer visits your site.

Share this post


Link to post
Share on other sites
  • 0
Then uninstall the "Currency block" and change line 22 of init.php from:

$cookie = new Cookie('ps');



$cookie = new Cookie('ps');
$cookie->id_currency = 2;



Change 2 to the ID of the currency you want to be used in the Front Office. This will force the currency to 2 whenever a customer visits your site.



IT WORKS .... THANK YOU VERY MUCH .....

Share this post


Link to post
Share on other sites
  • 0

Hi there, the solution works perfectly for previous versions, but in the new 1.4 doesn't, I was trying to solve that, so I have a temporal solution, (at least while some one else get a better solution)

In your headet.tpl file from your template directory add this in the line 63 or wherever your body tag is:

<body {if $page_name}onLoad="setCurrency(1);" id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}>


I just added the command that call the function to change the currency when loads the page "setCurrency();", you have to change the value for your prefered currency value

Share this post


Link to post
Share on other sites
  • 0

for v1.4 you can override the Tools class using the following code.

This code forces the Front Office currency to ZAR (or Rand), while leaving the Back Office currency whatever the default currency is.

class Tools extends ToolsCore
{
   public static function setCurrency()
   {
       global $cookie;
       $currency = Currency::getCurrencyInstance((int)Currency::getIdByIsoCode('ZAR'));
       if (is_object($currency) AND $currency->id)
           $cookie->id_currency = (int)($currency->id);
       return $currency;
   }
}

Share this post


Link to post
Share on other sites
  • 0
i have 2 currency, dollar & rupiah .. i want input the price in the admin (BO) with dollar ,, and appears in the website (FO) with Rupiah .. of course, after automatically converted ..

anyone can tell me the way to do that .. ?? :)

*thanks before for the answer .. :)


i hope , this module could be useful for you

http://prestashopmodul.com/en/11-multi-currency-solution.html

Share this post


Link to post
Share on other sites
  • 0

Thanks for your help

Y arriba Mexico!!!

 

 

Hi there, the solution works perfectly for previous versions, but in the new 1.4 doesn't, I was trying to solve that, so I have a temporal solution, (at least while some one else get a better solution)<br/><br/>In your headet.tpl file from your template directory add this in the line 63 or wherever your body tag is:<br/>

<body {if $page_name}onLoad="setCurrency(1);" id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}>

<br/>I just added the command that call the function to change the currency when loads the page "setCurrency();", you have to change the value for your prefered currency value

Share this post


Link to post
Share on other sites
  • 0

Anyone has purchased this one? Does it work properly?

 

I am using for my clients web store. working perfect...

Share this post


Link to post
Share on other sites
  • 0

for v1.4 you can override the Tools class using the following code.

 

This code forces the Front Office currency to ZAR (or Rand), while leaving the Back Office currency whatever the default currency is.

 

class Tools extends ToolsCore
{
public static function setCurrency()
{
	global $cookie;
	$currency = Currency::getCurrencyInstance((int)Currency::getIdByIsoCode('ZAR'));
	if (is_object($currency) AND $currency->id)
		$cookie->id_currency = (int)($currency->id);
	return $currency;
}
}

Hello,

Works for Prestashop 1.5

Thank you!

 

public static function setCurrency($cookie)
{

  $currency = Currency::getCurrencyInstance((int)Currency::getIdByIsoCode('UAH'));
 if (is_object($currency) && $currency->id)
  $cookie->id_currency = (int)$currency->id;
 return $currency;
}

Edited by doubleD

Share this post


Link to post
Share on other sites
  • 0

The problem with this solution is that it prevents users from being able to switch currencies. I need to have a separate default in front and back while maintaining the ability to change on the front.

 

for v1.4 you can override the Tools class using the following code.

 

This code forces the Front Office currency to ZAR (or Rand), while leaving the Back Office currency whatever the default currency is.

 

class Tools extends ToolsCore
{
public static function setCurrency()
{
	global $cookie;
	$currency = Currency::getCurrencyInstance((int)Currency::getIdByIsoCode('ZAR'));
	if (is_object($currency) AND $currency->id)
		$cookie->id_currency = (int)($currency->id);
	return $currency;
}
}

Share this post


Link to post
Share on other sites
  • 0

My solution:

 

////////////////////////////////////////////////////////////////////////////////////////////////
 // Override to show USD by default on front-end while maintaining KRW default in the back-end //
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /**
  * Set cookie currency from POST or default currency
  *
  * @return Currency object
  */
 public static function setCurrency($cookie)
 {
   if (Tools::isSubmit('SubmitCurrency'))
     if (isset($_POST['id_currency']) && is_numeric($_POST['id_currency']))
     {
       $currency = Currency::getCurrencyInstance($_POST['id_currency']);
       if (is_object($currency) && $currency->id && !$currency->deleted && $currency->isAssociatedToShop())
         $cookie->id_currency = (int)$currency->id;
     }

   if ((int)$cookie->id_currency)
   {
     $currency = Currency::getCurrencyInstance((int)$cookie->id_currency);
     if (is_object($currency) && (int)$currency->id && (int)$currency->deleted != 1 && $currency->active)
       if ($currency->isAssociatedToShop())
         return $currency;
       else
       {
         // get currency from context
         $currency = Shop::getEntityIds('currency', Context::getContext()->shop->id);
         $cookie->id_currency = $currency[0]['id_currency'];
         return Currency::getCurrencyInstance((int)$cookie->id_currency);
       }
   }
   $currency = Currency::getCurrencyInstance(2);
   if (is_object($currency) && $currency->id)
     $cookie->id_currency = (int)$currency->id;

   return $currency;
 }

Share this post


Link to post
Share on other sites
  • 0

Then uninstall the "Currency block" and change line 22 of init.php from:

 

$cookie = new Cookie('ps');

$cookie = new Cookie('ps');$cookie->id_currency = 2;

Change 2 to the ID of the currency you want to be used in the Front Office. This will force the currency to 2 whenever a customer visits your site.

 

 

hi Rocky,

 

what I need to do to make prestashop 1.5.4.1 work ?

 

thanks my friend.

Share this post


Link to post
Share on other sites
  • 0

prestashop 1.5 doesnt use $cookie variable, in new ps you have to use context object to achieve this

hi Vekia...

 

Is this correct line ? 

 

q59f.jpg

 

if yes, how I change ? 

 

$context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));$context->id_currency = 2;

 

like this not work...

 

if this line is wrong, what is correct line ?

 

thanks my friend.

Share this post


Link to post
Share on other sites
  • 0

you have to define whole new object, instead of :

$context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));$context->id_currency = 2;

just use:

$context->currency = new Currency(2);

Share this post


Link to post
Share on other sites
  • 0

you can use many currencies in prestashop, you can define default shop currency in back office: localization > localization

there is option to define default currency.

 

for what purposes you want different currencies? it's not useful 

Share this post


Link to post
Share on other sites
  • 0

Hello,

 

I have the 1.5.6.1 and need the currecy number 2 in the frontoffice without allowing to change it and at the same time keep USD as default currency. What't the file name where I have to make the changes?

 

Best regards.

Share this post


Link to post
Share on other sites
  • 0

Hello, I found a way around to solve my problem. As I don't need people to access my store from other countries, I turned on the geolocation feature and blocked everyone but my country. Also, turned off the Block Currency. This way, I have the USD as the default currency but in the frontpage is always displayed my country's currency.  :)

Share this post


Link to post
Share on other sites
  • 0

Hello,

 

How can I use this default currency override in multistore?

 

Two shops have the same default currency in BO.

I need one shop to show default currency in front office and another to show non-default currency on front office, so that user does not have to change it manually.

 

Is it possible?

PrestaShop version 1.5.6.2

 

 

 

you have to define whole new object, instead of :

$context->currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));$context->id_currency = 2;

just use:

$context->currency = new Currency(2);

 

Share this post


Link to post
Share on other sites
  • 0

Hello....

 

i just install Prestashop 1.5.6.2 for my web store.

i want to use US Dollar as default currency in Back Office and Rupiah as default currency in Front Office (only one currency).

My products is imported, so have to use US Dollar.

 

Anybody can help me, please....

 

 

Best regards

Share this post


Link to post
Share on other sites
  • 0

Hi,

For Prestashop 1.6.0.9 force currency in frontend.

 

/public_html/classes/tools.php

Replace  line 431
$currency = Currency::getCurrencyInstance((int)$cookie->id_currency);
with
$currency = Currency::getCurrencyInstance((int)$cookie->id_currency=2);

Replace line 433
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
with
$currency = Currency::getCurrencyInstance(Configuration::get('id_currency'));
 

It works on my website.

Edited by cristidam

Share this post


Link to post
Share on other sites
  • 0
class Tools extends ToolsCore
{
	public static function setCurrency()
	{
		global $cookie;
		$currency = Currency::getCurrencyInstance((int)Currency::getIdByIsoCode('GBP'));
		if (is_object($currency) AND $currency->id)
			$cookie->id_currency = (int)($currency->id);
		return $currency;
	}
}

eg. for GBP.. in PS1.4

but my question is:

 

how to exclude payment modules?

does it work for home, product pages, categories or that override works for any page?

I need to exclude the payment module, if it has to show another currency with the correct exchange..

thanks

Share this post


Link to post
Share on other sites
  • 0

hello, the real problem is another:

if the default shop currency is GBP but the front currency for payment method is EUR

the final invoice with this override method is GBP and it's not good...it should be EUR

so I need to show GBP as default FRONT currency BUT in case the user chooses a payment method which allows EUR only

after the final callback from the gateway the invoice must be in EUR... and THEN just the front currency has to return in GBP

please, how to do it?

 

Bellini,

"...while leaving the Back Office currency whatever the default currency is."

do you mean that in my case I should leave EUR as default shop currency and use the override for the front part only?

Edited by mmsh

Share this post


Link to post
Share on other sites
  • 0

Hi,

For Prestashop 1.6.0.9 force currency in frontend.

 

/public_html/classes/tools.php

Replace  line 431
$currency = Currency::getCurrencyInstance((int)$cookie->id_currency);
with
$currency = Currency::getCurrencyInstance((int)$cookie->id_currency=2);

Replace line 433
$currency = Currency::getCurrencyInstance(Configuration::get('PS_CURRENCY_DEFAULT'));
with
$currency = Currency::getCurrencyInstance(Configuration::get('id_currency'));
 

It works on my website.

 

 

 

this not work, because when i try to do it, cart is empty and i dont get checkout. beyond it, we get this error:

 

Use of undefined constant PS_ROUND_HALF_DOWN - assumed 'PS_ROUND_HALF_DOWN'

 

 

how to solve all this?

Share this post


Link to post
Share on other sites
  • 0

Then uninstall the "Currency block" and change line 22 of init.php from:

 

$cookie = new Cookie('ps');

$cookie = new Cookie('ps');$cookie->id_currency = 2;

Change 2 to the ID of the currency you want to be used in the Front Office. This will force the currency to 2 whenever a customer visits your site.

 

 hi ,

 

does it work on 1.6.0.14 ? 

and what is the path of the file 

 

thank you 

Share this post


Link to post
Share on other sites
  • 0

Im using the latest version of Prestashop 1.6.1.4 and I am using USD as default currency in the backend (Importe products with cost in USD) of the store but I would like to use MXN (mexican peso) in the front end. Also I would like that PayPal module takes the MXN as input but in the website where is displayed the amount of the order is changed to USD taking into account the currency rate of Prestashop NOT PayPal.

Share this post


Link to post
Share on other sites
  • 0

I have been scratching my head whole day but cannot find the reason for this issue. My site is ginbaba.com

 

 I am having a similar problem, it is not possible to change the currency on the front office. I tried to make a new installation of prestashop 1.6.x  and change the currency but that did not worked either. 

 

I hope someone can help. I have cleaned all the cashes ...... kindly help anyone .....

Share this post


Link to post
Share on other sites
  • 0

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
  • 0

 

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.

 

Hi

you copied this solution from another page on the web.... that's ok, but i was looking for some explanations more, the text is not clear for whom that are not developers :-)

 

Can you please tell me what it means?

 

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

 

Can you make an example? 

So, in my backoffice i pay EUR to my suppliers and i calculate the selling price in EUR.

To do this, if i don't misunderstand, i set up the default currency to EUR.

But I want my frontoffice to show another currency, for example USD, because my buyers will pay USD to me. 

So how should i change that line?

 

Thank you very much for your help :-)

 

V

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

×