FX currency factor for SAR and XDR is 1

  • Posts: 35
  • Thank you received: 3
8 years 4 months ago #244697

-- url of the page with the problem -- : shop.smartgart.com
-- HikaShop version -- : 2.6.3
-- Joomla version -- : 3.5.1
-- PHP version -- : 5.5
-- Browser(s) name and version -- : Chrome
-- Error-message(debug-mod must be tuned on) -- : SAR 1
XDR 1

Hi, I am running HikaShop Business on default currency Euro and consume hourly currency (FX) updates.

Looking into ... > Hikashop > Configuration > System > Currency, I am successfully using CHF, USD and other major currencies. But it looks like as if SAR (Saudi Ryial) and XDR (IMF special drawing rights) are not updated because they stand on 1 (rather than a meaningful fractional number).

Perhaps they can be included in the future because I am targeting Arabic clients, and XDR is useful for customs declarations (the 300 XDR limit for CN 23 exports).

best regards

Klaus

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13378
  • MODERATOR
8 years 4 months ago #244699

Hi,

The currency rate auto update plugin uses the rates from either the European Central Bank or Yahoo Finances.
So for the rates to be updated for your currency, it requires that the service you selected supports that currency, and that this service uses the same currency code than the currency code set for that currency in HikaShop.
So either the currency code is different (you can check it in the menu System>Currencies and change it if necessary) or the service you selected doesn't support the currency you're using.

The following user(s) said Thank You: hactic

Please Log in or Create an account to join the conversation.

  • Posts: 35
  • Thank you received: 3
8 years 2 months ago #250351

Thanks Nicolas - I overlooked your answer by the time, became silly and coded a little workaround (and probably re-invented the wheel) and now directly insert into the database from a php page that is hourly called from a cron-job. Yahoo has all those exotic currencies; unfortunately PayPal does not handle them. Your suggestion is perfect.

best regards

Klaus



wget "http://www.....com/import/fx-xdr.php" -O /dev/null -o /dev/null

fx-xdr.php:

<?php
$content = file_get_contents('http://download.finance.yahoo.com/d/quotes.csv?s=EURXDR=X&f=nab');

$tok = explode(',', $content);

$fx = 0.1; // chose low value as default (currently roundabout 0.8)
if($tok[1] > 0 && $tok[2] > 0) $fx = ($tok[1] + $tok[2]) / 2;
else if($tok[1] > 0) $fx = $tok[1];
else if($tok[2] > 0) $fx = $tok[2];

$time = time();

$mysqli = new MySQLi("localhost", ...);
if($mysqli->connect_errno) printf("%d: %s<br>/n", $mysqli->connect_errno, $mysqli->connect_error);
$update = "UPDATE joomla_hikashop_currency SET currency_rate = '$fx', currency_modified = '$time' WHERE currency_code = 'XDR'";

if ($mysqli->query($update) === TRUE) {
	echo "Record updated successfully";
} else {
	echo "Error updating record: " . $mysqli->error;
}
?>

Last edit: 8 years 2 months ago by hactic.

Please Log in or Create an account to join the conversation.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
8 years 2 months ago #250352

Hi,

I recommend you to use the JDatabase structure in order to access to the website database.
It will be easier and more secure.
docs.joomla.org/Accessing_the_database_using_JDatabase

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.
The following user(s) said Thank You: hactic

Please Log in or Create an account to join the conversation.

Time to create page: 0.064 seconds
Powered by Kunena Forum