简体   繁体   中英

Currency API in Drupal

I build a webshop, but the client wants a second currency, HKD. In the node-record.tpl.php file I found the line responsible for displaying the price:

print uc_currency_format($node->sell_price);

I looked into the Drupal documentation, and found the function currency_api_converter . To use it, I thought it should be like this:

print ' ('. currency_api_convert('RMB', 'EUR', $node->sell_price) .')</div>';

But for some reason, all I get is a sort of Array error:

在此处输入图片说明

What am I doing wrong?

Regards in advance

Function currency_api_convert() returns array of values

$result['value'] = $value;
$result['rate'] = $rate;
$result['timestamp'] = $timestamp;
$result['date'] = $date;
$result['time'] = $time;
$result['status'] = TRUE;
$result['message'] = 'success';

Then you should to rewrite your code to

$convert = currency_api_convert('RMB', 'EUR', $node->sell_price);
print ' ('. $convert['value'] .' EUR)</div>';

I build a webshop, but the client wants a second currency, HKD. In the node-record.tpl.php file I found the line responsible for displaying the price:

print uc_currency_format($node->sell_price);

I looked into the Drupal documentation, and found the function currency_api_converter . To use it, I thought it should be like this:

print ' ('. currency_api_convert('RMB', 'EUR', $node->sell_price) .')</div>';

But for some reason, all I get is a sort of Array error:

在此处输入图片说明

What am I doing wrong?

Regards in advance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM