News:

Support the VirtueMart project and become a member

Main Menu

Change currency per language?

Started by drizzt99, August 08, 2012, 21:06:41 PM

Previous topic - Next topic

drizzt99

Hi,
I have a multilingual shop.
I've setup the products in one language to be in the currency of this language (e.g. English -> USD and Hebrew -> NIS).
Is there a way to show the prices in NIS when choosing the Hebrew language and the prices in USD when viewing the English language?
Thanks

alatak

Hello,

I have heard that you can do that with the GeopIp plugin. But i have not used it myself.

drizzt99

Why should it be related to the geoIP plugin?
I just need fixed prices in USD for English and fixed prices in NIS for heb.  The user switches between the languages manually.

alatak

Hello,

It is a solution used by somebody else to force the language of the website according to the IP, and to force the currency also.

The other solution is to write a module that changes the currency according to the language.
I don't think that exists yet.

drizzt99


drizzt99

#5
Ok, I'm trying something, but it's not working.
Here's my code:

if ($_SESSION['lang']  == "he-il") {
$virtuemart_currency_id = 67;
}else{
$virtuemart_currency_id = 144;
}

$virtuemart_currency_id = $mainframe->getUserStateFromRequest( "virtuemart_currency_id", 'virtuemart_currency_id', $virtuemart_currency_id );


It doesn't change anything.  How can I set the userState var to be the correct currency ID?

alatak

Hello

use this instead


$jlang =JFactory::getLanguage();
$jlang->getDefault()


will return you the language tag

and to set the user state
$mainframe->setUserState( "virtuemart_currency_id", $virtuemart_currency_id );

for the user states documentation you can read this http://docs.joomla.org/How_to_use_user_state_variables

drizzt99

Hi,
Thanks. It's working strange... it's as if the session changes after I refresh the screen.
Anyway - is there a way to setup a fixed price per currency and not a conversion (e.g. disable the conversion plugin)?

SamF

#8
Hello,

"fixed price per currency" means fixed exchange rate, right?

The easy way is to set non-zero rates in currencies table (your_site/administrator/index.php?option=com_virtuemart&view=currency). Try 1USD = 1EUR, and see the prices in both currencies... What's nice in VM2, is that you can even set your private VM$)).

If you want to dig deeper, it's here: your_site\administrator\components\com_virtuemart\plugins\currency_converter\convertECB.php

drizzt99

Hi,
THanks for the reply.
I do not mean "fixed exchanged rate".
I mean "fixed prices".
So, for instance, one product would cost 10$ and 100 in another currency.
Another product would cost 20$ and 150 in another currency.

jjk

I think this doesn't work. It is possible to assign different country specific price rules to a product, but then the customers would only see the correct price after they have entered their address in the cart.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

drizzt99

hmmm...
So... I can create products in 1 language, and the same products in another language with different prices.
The only thing's that's left is to force a certain currency on a certain language (e.g. USD for English and other currencies for other languages).
I tried to change the converter module, but it doesn't work. 
Here's my code:

$jlang =JFactory::getLanguage();
$lang = $jlang->getTag();

if ($lang == "he-il") {
$virtuemart_currency_id = 67;
}else{
$virtuemart_currency_id = 144;
}

$virtuemart_currency_id = $mainframe->setUserState("virtuemart_currency_id", $virtuemart_currency_id);

Any idea why it doesn't work?
Thanks

SamF

#12
Hello,

Quote from: drizzt99 on August 18, 2012, 18:58:18 PM
So, for instance, one product would cost 10$ and 100 in another currency.
Another product would cost 20$ and 150 in another currency.

What is this another currency? Is it common base currency for product 1 and product 2? Or two products have individual base currencies? So, the rate between products 1 and 2 is 100/150?  How about the payment currency? Why not just use the ILS/USD exchange rate (fixed or market)? Too many "? ? ?", sorry)) Still, there is a couple of hack-free methods... 1) set individual currency for each product, 2) set separate shop for each language...

You can force the currency settings per language or visitor IP, but the visitor can force his or her language for the one with cheapest prices, or use proxy IP anywhere from Alaska to Timbuktu...

drizzt99

Hi,
The other currency is NIS in this case, for both products.
I don't mind if users get to the site from another country to get the "cheaper" price.
I sent the code that was supposed to "force" the currency setting per language.  It's not working for some reason. 
What I did is the following:
I've created the products in English in the category "Products".  I've set the prices there for USD.
Then, I've created a copy of this category and products, only in Hebrew.   I've set the prices there for NIS.
Then I've added the code above so it would change the currency in the session according to the site's language:

$jlang =JFactory::getLanguage();
$lang = $jlang->getTag();

if ($lang == "he-il") {
$virtuemart_currency_id = 67;
}else{
$virtuemart_currency_id = 144;
}

$virtuemart_currency_id = $mainframe->setUserState("virtuemart_currency_id", $virtuemart_currency_id);

Can you please guide me how to do it?
I'd rather not use 2 different sites for this.

SamF

your_site\modules\mod_virtuemart_currencies\mod_virtuemart_currencies.php

lines between 26 and 37