WilkinsIT Posted April 27, 2017 Share Posted April 27, 2017 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? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted April 27, 2017 Share Posted April 27, 2017 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. 0 Quote Link to comment Share on other sites More sharing options...
WilkinsIT Posted April 27, 2017 Author Share Posted April 27, 2017 Yeah i was thinking about the first one. I would just need to pull the exchange rate variable "out" do the 1.02 and then write it back before the pricing update. I guess i have some hunting to do for the right variables etc. 0 Quote Link to comment Share on other sites More sharing options...
mauwiks Posted February 7, 2020 Share Posted February 7, 2020 Can you share your hook for this? 🙂 Thanks! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.