VirtueMart Forum

VirtueMart 2 + 3 + 4 => Administration & Configuration => Topic started by: hk on March 27, 2014, 13:41:40 PM

Title: Currency conversion is not dynamic (real)
Post by: hk on March 27, 2014, 13:41:40 PM
Hi,

My store currency is INR and the Payment method for customers from USA is Paypal which is configured in USD currency.
The currency is getting converted to USD for the customers but the conversion rate is not real. For all the orders which I received in past 1 month, the currency conversion was same.

In the configuration, Select a currency converter module is set to default i.e. convertECB.php (/administrator/index.php?option=com_virtuemart&view=config) and the exchange rate for all currencies is set to 0.00000 (/administrator/index.php?option=com_virtuemart&view=currency).

Can you let me know, what is causing the currency conversion as same for all orders.


Thanks.
Title: Re: Currency conversion is not dynamic (real)
Post by: Milbo on March 29, 2014, 12:36:38 PM
Usually the currency rate is updated 4 times a day.
Title: Re: Currency conversion is not dynamic (real)
Post by: hk on March 29, 2014, 12:47:32 PM
But all my orders had the same exchange rate. This is surprising.
Do you foresee any bug in the VM 2.0.18c?

How should I ensure that the updates are working properly.
Also as a workaround until I fix the issue, can you let me know where should I change the exchange rate for USD so that all my orders take this value for conversion.
Title: Re: Currency conversion is not dynamic (real)
Post by: StefanSTS on March 29, 2014, 17:14:04 PM
I foresee, that your site is vulnarable, because you use a version prior to 2.0.24c, which fixed earlier security issues.

Since 2.0.18 was quite some time ago, your problem might be fixed in 2.0.26d.

Mirror installation, test and go! :-)

Stefan

PS. Same for Joomla, if you still run on an old version.
Title: Re: Currency conversion is not dynamic (real)
Post by: hk on March 31, 2014, 14:08:41 PM
Thanks for the note!
But I cannot quickly upgrade and I will have to do lot of testing of new version before implementation.

Can you let me know the workaround solution.

Thanks.
Title: Re: Currency conversion is not dynamic (real)
Post by: hk on April 25, 2014, 12:38:13 PM
I upgraded from 2.0.18a to 2.0.26d in test region.
But the currency conversion is not happening at the real exchange rate.

Yesterday, I tried to shop the product, it showed $37.05 and today it shows the same.

Can you please advise.

Thanks.
Title: Re: Currency conversion is not dynamic (real)
Post by: jenkinhill on April 25, 2014, 17:10:15 PM
Look in Joomla root/cache/convertECB/ where you should see a file with a name something like
d9b47f88a91460d2518e2e4dc98dff5f-cache-convertECB-59d2660627d124d1f4d8403e63461a9a.php
That file contains is the last downloaded conversion rate. This should be auto updated up to 4 times a day.
Title: Re: Currency conversion is not dynamic (real)
Post by: hk on April 25, 2014, 17:42:30 PM
I could find a file 9833e8c7ecc062b4768aac8b70f23fd1-cache-convertECB-59d2660627d124d1f4d8403e63461a9a.php
The Last Modified date for this is Yesterday 4:21 PM IST.
This is the approximate time when I started testing the upgraded VM by creating orders.

I think something is stopping from getting the file updated.

This same file is available in my Live site which uses VM 2.0.18a

Should I delete this file and create orders to see if the latest version is picked?
Title: Re: Currency conversion is not dynamic (real)
Post by: jenkinhill on April 25, 2014, 17:58:33 PM
No the update is obviously being downloaded. You should check the fil;e to make sure it does have an exchange rate for your currency.
Title: Re: Currency conversion is not dynamic (real)
Post by: hk on April 25, 2014, 18:15:21 PM
I'm using INR and USD; both currencies are listed in that file.

Also, I could see there is a file daily.xml in cache folder which has similar data with
Cube time='2014-01-21'
Title: Re: Currency conversion is not dynamic (real)
Post by: martinex on November 25, 2014, 04:45:12 AM
Quote from: Milbo on March 29, 2014, 12:36:38 PM
Usually the currency rate is updated 4 times a day.

I just spent few hours finding out why my exchange rates are not updated... The problem is IMO in the convertECB.php:
$cache->setLifeTime(86400/4); // check 4 time per day
where we set seconds as the lifeTime which is then multiplied by 60 in libraries/joomla/cache/storage.php ctor... so since Joomla is expecting minutes here, we are actually updating once every 15 days.
I've changed this to:
$cache->setLifeTime(24*60/4); // check 4 time per day
and I'm fine now.

I've checked this also in latest Joomla/VM versions, so probably there is a serious bug here (or I have something really messed up in my installation)
Title: Re: Currency conversion is not dynamic (real)
Post by: Milbo on November 26, 2014, 11:17:29 AM
Thank you for pointing that out. Should be fixed next version
Title: Re: Currency conversion is not dynamic (real)
Post by: hk on April 25, 2015, 10:35:43 AM
I'm unable to find the code in the file libraries/joomla/cache/storage.php as mentioned below:

Quote from: martinex on November 25, 2014, 04:45:12 AM
I just spent few hours finding out why my exchange rates are not updated... The problem is IMO in the convertECB.php:
$cache->setLifeTime(86400/4); // check 4 time per day
where we set seconds as the lifeTime which is then multiplied by 60 in libraries/joomla/cache/storage.php ctor... so since Joomla is expecting minutes here, we are actually updating once every 15 days.
I've changed this to:
$cache->setLifeTime(24*60/4); // check 4 time per day
and I'm fine now.


The code available is:
public function __construct($options = array())
{
$config = JFactory::getConfig();
$this->_hash = md5($config->get('secret'));
$this->_application = (isset($options['application'])) ? $options['application'] : null;
$this->_language = (isset($options['language'])) ? $options['language'] : 'en-GB';
$this->_locking = (isset($options['locking'])) ? $options['locking'] : true;
$this->_lifetime = (isset($options['lifetime'])) ? $options['lifetime'] * 60 : $config->get('cachetime') * 60;
$this->_now = (isset($options['now'])) ? $options['now'] : time();

// Set time threshold value.  If the lifetime is not set, default to 60 (0 is BAD)
// _threshold is now available ONLY as a legacy (it's deprecated).  It's no longer used in the core.
if (empty($this->_lifetime))
{
$this->_threshold = $this->_now - 60;
$this->_lifetime = 60;
}
else
{
$this->_threshold = $this->_now - $this->_lifetime;
}

}


Can you please let me know where should I update, so that currency rates are updated 4 times a day.

Thanks.
Title: Re: Currency conversion is not dynamic (real)
Post by: jenkinhill on April 25, 2015, 13:38:36 PM
The current VM 3.0.8 version updates the ECB exchange rate xml file daily, on the first occasion the store site is used on that day.  There is no point trying to check for an xml file more often as it is only updated once each day by the ECB.............
Title: Re: Currency conversion is not dynamic (real)
Post by: hk on April 25, 2015, 13:43:25 PM
Thanks for the note!

I'm still using VM 2.0.26d, what should I change so that exchange rates are updated at least daily.
I need to know this, until I upgrade to VM 3.0.8

Thanks.