Jump to content

Module: Currency Conversion Service


ryan
 Share

Recommended Posts

  • 4 years later...

I'm having troubles using the methods ->getName() and ->getNames()

$cc = wire('modules')->get('ServiceCurrencyConversion');
$currencyArray = $cc->getNames(); // array (0)
$currency = 'HKD';
$cc->getName($currency); // null

warnings:

PHP Warning: Undefined array key "HKD" in .../ServiceCurrencyConversion/ServiceCurrencyConversion.module:341
PHP Warning: Trying to access array offset on value of type null in .../ServiceCurrencyConversion/ServiceCurrencyConversion.module:341

I logged into my openexchangerates.org account and there seems to be no outage.

Any ideas what this could be?

Link to comment
Share on other sites

@fruid Make sure you are using the newest version (version 3). Go to Modules > Site > ServiceCurrencyConversion. At the bottom is a checkbox to "Refresh rate data now". Check the box and save. Now make sure that you see HKD in the table shown on the configuration screen. If you don't, edit your /site/modules/ServiceCurrencyConversion/currencies.txt file and make sure it's in there, adding it if it isn't, and refreshing again. 

If you don't see any data loaded, I'm guessing that your server is blocking the outbound http request to the exchange rates API. You could modify the module WireHttp call to force it to use CURL or fopen, depending on what your server supports. Let me know if you need help. 

Link to comment
Share on other sites

1 hour ago, ryan said:

At the bottom is a checkbox to "Refresh rate data now"

Thanks @ryan

I didn't see that checkbox but I did see an input field Number of Seconds to Cache Exchange Rate Data

It was set to 86400, so I set it to 0 and saved. Then I was able to see the table with all codes, names, symbols and rates. Now I also see the checkbox. Weird, I am still on version 3.

Anyways, yes, HKD is listed. (Actually not one currency was working before).

Now it seems to work again. I wonder, if I need to do this regularly i.e. lower the number of seconds when the cache is cleared?

Link to comment
Share on other sites

@fruid The cache time should be fine. I'm guessing maybe it just didn't work on the first use for whatever reason, and the non-working data was cached. 

  • Like 1
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...