【问题标题】:INR to USD convert values in opencartINR 到 USD 转换 opencart 中的值
【发布时间】:2014-06-10 09:52:23
【问题描述】:

如何在 opencart 中将 INR 卢比兑换成美元。我已经尝试过下面的代码......

    $json_from = number_format($item_total, 2, '.', '');
    $url = "http://rate-exchange.appspot.com/currency?from='.$json_from.'&to=USD";
    $jsons = @file_get_contents($url);
    $json_data = json_decode($jsons, true);
    $to_cur = $json_data['results'][0];


    $data['PAYMENTREQUEST_0_ITEMAMT'] = $to_curr;
    $data['PAYMENTREQUEST_0_AMT'] = $to_curr;

【问题讨论】:

标签: php arrays opencart json


【解决方案1】:

您对 api 的 url 调用不正确,您需要像这样调用,

$url = "http://rate-exchange.appspot.com/currency?from=INR&to=USD";

从那里您将获得将 INR 转换为 USD 的转换率,就像现在给出 0.0168728 并与您的金额相乘以获得预期结果。

旁注:您也可以将第三个参数传递为&q=4300,直接从api获取转换后的值。 Example

DEMO.

【讨论】:

  • 这是正确的方法吗? $url = "http://rate-exchange.appspot.com/currency?from=INR&to=USD&q=$json_from";
  • 是的,它是正确的。我已经更新了我的演示,请检查。
猜你喜欢
  • 2014-08-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-19
  • 2016-08-17
  • 2016-06-13
  • 2015-04-07
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多