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
Hello,
I have heard that you can do that with the GeopIp plugin. But i have not used it myself.
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.
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.
Alrighty then :)
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?
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
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)?
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
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.
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.
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
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...
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.
your_site\modules\mod_virtuemart_currencies\mod_virtuemart_currencies.php
lines between 26 and 37
What do I do with it?
This is where I put my code...
Ok,
I've made the following changes:
Template file -
Ok,
I did the change:
<?php // no direct access
defined('_JEXEC') or die('Restricted access'); ?>
<!-- Currency Selector Module -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("form#converter").submit();
});
</script>
<?php echo $text_before ?>
<form action="<?php echo JURI::getInstance()->toString(); ?>" method="post" id="converter">
<br />
<?php echo JHTML::_('select.genericlist', $currencies, 'virtuemart_currency_id', 'class="inputbox"', 'virtuemart_currency_id', 'currency_txt', $virtuemart_currency_id) ; ?>
<input class="button" type="submit" name="submit" value="<?php echo JText::_('MOD_VIRTUEMART_CURRENCIES_CHANGE_CURRENCIES') ?>" />
</form>
Inside the module main file I've added this:
$jlang =JFactory::getLanguage();
$lang = $jlang->getTag();
if ($lang == "he-il") {
$virtuemart_currency_id = 67;
}else{
$virtuemart_currency_id = 144;
}
It still doesn't work... any idea why?
Thanks
Hello,
$jlang =JFactory::getLanguage();
$lang = $jlang->getTag();
if ($lang == "he-IL")
{$virtuemart_currency_id = 67;}
else
{$virtuemart_currency_id = 144;}
$mainframe->setUserState("virtuemart_currency_id", $virtuemart_currency_id);
works for me... does not require to submit the form.
That's the first thing I tried.
It doesn't work... for some reason, it works when I use the form, but doesn't work when I just switch language...
Can you send me a link of where it works for you?
http://virtuext.com/joomla25/virtuemart (http://virtuext.com/joomla25/virtuemart)
Switch the language; English comes with $, French gives you old good French francs).
It's not working for you either.
I click on the French flag, and price remains in USD.
If I click a second time, it switches to Euros.
Then, when I click on the English flag, I get the site in Eng, but prices in Euros.
Click a second time on the Eng flag, and you get the prices in USD.
This is exactly what happens to me. There's the "lag" in switching the currency.
Any way around this problem?
Quote from: drizzt99 on August 20, 2012, 12:04:45 PM
I click on the French flag, and price remains in USD.
If I click a second time, it switches to Euros.
...
Any way around this problem?
Cache...
When you switch the language, the currency selector switches too, right? So does the vm_currency_id. But the prices
on the page (if any are shown) remain in previous currency until you refresh the page. You do it by clicking on the flag again, or F5...
Click on the flag once, then go to the category or product details page. Did it work?
So, the question is "how to clean cache on lang switch?".
P.S.: I think, it
does work (in terms of your task). Set aside, if your browser is in certain language, you will get the page in certain currency at entry.
hmmm...
So if it is cache, is there a way to disable cache for prices only?
Would appreciate, if you find out the answer, then share it))
Ok,
I think it's done right now, but it's changing core files, which is bad for biz.
Add this code:
$lang =& JFactory::getLanguage();
if ($lang->get('tag') == "he-IL" ) {
$currencyId = 67;
}
else {
$currencyId = 144;
}
In 2 places in the file (/administrator/components/com_virtuemart/helpers/currencydisplay.php):
1) Right after public function getCurrencyForDisplay( $currencyId=0 ){
2) Right after self::$_instance = new CurrencyDisplay($vendorId);
Just don't forget to change he-IL to french and the 67 to the french number.
Worked for me...
Doesn't work
PHP Fatal error: Call to a member function get() on a non-object in /var/www/vhosts/insanto.org/httpdocs/administrator/components/com_virtuemart/helpers/currencydisplay.php on line 96
Sory, no comment about this solution? May be somebody knows one or more solutions?
Hello
You forgot to mention your joomla, vm and PHP version.
Regards
Sorry.
We have two shops.
One one Joomla is 2.5.7 and one more 2.5.4
Virtuemart 2.0.10 och Virtuemart 2.0.12
PHP on the server 5.2.17
:)
hi, i think i had reply on you :)
Please upgrade your php to 5.3.x and post your results.
Regards
Has anyone got a solution for this??? I think it's an pretty important feature. Someone must have made it work
(i want to change currency, when language is changed)
//Anders J.
Did you try this: https://forum.virtuemart.net/index.php?topic=106192.msg355855#msg355855 ?
That worked like a charm. Thank you very much. Where do i find the virtuemart_currency_id list? I dont know what IDs Danish Kroner, Swedish Kroner, Norweigan Kroner and Euro has.
To clarify what i did to make this work, to future troubleshooters:
I pasted the code under this line, after the line 37: $virtuemart_currency_id = $mainframe->getUserStateFromRequest( "virtuemart_currency_id", 'virtuemart_currency_id',JRequest::getInt('virtuemart_currency_id', $vendor_currency['vendor_currency']) ); ----- in the \modules\mod_virtuemart_currencies\mod_virtuemart_currencies.php file.
$jlang =JFactory::getLanguage();
$lang = $jlang->getTag();
if ($lang == "da-DK")
{$virtuemart_currency_id = 208;}
elseif ($lang == "se-SV")
{$virtuemart_currency_id = 752;}
elseif ($lang == "no-NO")
{$virtuemart_currency_id = 578;}
else
{$virtuemart_currency_id = 978;}
The Currency IDs are random though..
There is no "list", I think. Not in VM backend. Browse your database table jos_virtuemart_currencies for virtuemart_currency_id.
Again thanks a lot. That really helped out. Everything is working perfectly now. Except i can't remove the decimals from my prices(even when disabling it in administration). But that is different topic :-P
Hi. I tried this plugin: http://www.easyjoomla.org/virtuemart-language-currency-switcher (http://www.easyjoomla.org/virtuemart-language-currency-switcher)
And it works just like I need it ;)
Hi to all,
This feature is also implemented in Artio's Joomsef for anyone interested. (We had asked this to the developers)
Rgrds,
Chris
Sent from my BlackBerry 9360 using Tapatalk
Quote from: drizzt99 on August 20, 2012, 12:48:00 PM
Ok,
I think it's done right now, but it's changing core files, which is bad for biz.
Add this code:
$lang =& JFactory::getLanguage();
if ($lang->get('tag') == "he-IL" ) {
$currencyId = 67;
}
else {
$currencyId = 144;
}
In 2 places in the file (/administrator/components/com_virtuemart/helpers/currencydisplay.php):
1) Right after public function getCurrencyForDisplay( $currencyId=0 ){
2) Right after self::$_instance = new CurrencyDisplay($vendorId);
Just don't forget to change he-IL to french and the 67 to the french number.
Worked for me...
Thanks! works for me :D
hello
do you think its possible, with your code, to change currencie for a specific category ?
I mean, category number instead of a language
Products of Category1 (11111)=> $ other Category Products=>€
if ($cat==11111 ) {
$currencyId = 67;
}
else {
$currencyId = 144;
}
Thank You