Jump to content

how to get currency exchange rate?


Remitur

Recommended Posts

How do I get the currency exchange rate used by WHMCS?

 

I need the value which is automatically updated daily, used to update service prices in Setup => Payments => currencies ... does exist any system variables to get it, or do I have to read it from the db ? :?:

Link to comment
Share on other sites

I think you'll have to read it from the database.

 

if it helps, I can share a cut-down version of an action hook I wrote for a client - they had two currencies in their setup and wanted access to the exchange rate...

 

<?php

use Illuminate\Database\Capsule\Manager as Capsule;

function hook_currency_exchange_rates($vars) 
{
   $exchangerate = Capsule::table('tblcurrencies')
               ->where('default', '0')
               ->get();

   return array("exchangerate" => $exchangerate[0]->rate);
}
add_hook("ClientAreaPage", 1, "hook_currency_exchange_rates");
?>

that will create a Smarty variable, {$exchangerate}, which you can use in the client area.

 

if you have more than two currencies and require the rate of a specific currency, then you can simply change the where statement to look at the 'id' or 'code' values instead.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated