Jump to content

Add to an Exchange Rate


WilkinsIT

Recommended Posts

Hello,

 

We would like to be able to add a certain percentage to the exchange rate.

 

For example, we want to be able to add 2% to whatever the exchange rate that comes in from the auto-update exchange. This would slightly inflate the exchange rate for anyone purchasing not in the home currency. For example, if the USD rate was 0.7361 for the day, it would actually convert at 0.7508.

 

I looked through the hook references and currency module and couldn't see anyway to grab this value as it's being updated and add a number to it. Anyone have any ideas?

Link to comment
Share on other sites

I looked through the hook references and currency module and couldn't see anyway to grab this value as it's being updated and add a number to it. Anyone have any ideas?

hmm.. possibly you could use a PreAutomationTask hook to run after the exchange rate task and before the product pricing update?

 

http://docs.whmcs.com/Crons#Hook_Points

 

I assume you would just let the exchange rates task do it's thing, and then pull the new USD exchange rate from the database, multiply it by 1.02 (same as adding 2%) and then send that updated value back to the database... then allow the cron to continue with its remaining tasks...

 

the only other ways I can think of would be worse, e.g you write your own exchange rate hook (e.g pulling the values from https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml) and then perform the necessary calculations on it (including your 2% addition), run it before the cron and disable the default exchange rates task from the cron...

 

... or do the opposite, let the cron run in full (perhaps skipping product pricing update), run your 2% hook, then run another cron just to update the prices.

 

if you can do it, I think the first would be the better solution. :idea:

Link to comment
Share on other sites

  • 2 years later...

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