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

What do I do with it?
This is where I put my code...

drizzt99

#16
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

SamF

Hello,

Code (your_site\modules\mod_virtuemart_currencies\mod_virtuemart_currencies.php after line 37) Select

$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.

drizzt99

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?

SamF

#19
http://virtuext.com/joomla25/virtuemart

Switch the language; English comes with $, French gives you old good French francs).

drizzt99

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?

SamF

#21
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.

drizzt99

hmmm...
So if it is cache, is there a way to disable cache for prices only?

SamF

Would appreciate, if you find out the answer, then share it))

drizzt99

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...

blistar

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


blistar

Sory, no comment about this solution? May be somebody knows one or more solutions?

bytelord

Hello

You forgot to mention your joomla, vm and PHP version.

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!

blistar

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

:)


bytelord

hi, i think i had reply on you :)

Please upgrade your php to 5.3.x and post your results.

Regards
Production: Joomla 2.5.8 | VM 2.0.14 | PHP 5.3.13
Testing     : Joomla 2.5.8 | VM 2.0.16 | PHP 5.3.8
Testing     : Joomla 2.5.8 |    VM 2.1   | PHP 5.3.8

- Don't Forget to mark thread as solved when it is solved!
- Please do not PM with support questions, use the forum!