Jump to content

How to add a currency that is not supported by default?


namhost

Recommended Posts

I added currency = NAD. Which is Namibian Dollar. NAD is the official code for this currency, but it's not widely used because 1 NAD = 1 ZAR. ZAR = South African Rand. So how would I be able to go about adding NAD and making the price update work? I.e. That it always sets the value the same as whatever ZAR is?

Perhaps another way would be to execute a SQL query right after currencies are updated. Is there a hook for that?

Link to comment
Share on other sites

45 minutes ago, namhost said:

I added currency = NAD. Which is Namibian Dollar. NAD is the official code for this currency, but it's not widely used because 1 NAD = 1 ZAR. ZAR = South African Rand. So how would I be able to go about adding NAD and making the price update work? I.e. That it always sets the value the same as whatever ZAR is?

I read that question, and my initial thought was "just add it!"... but on reflection, this could get real tricky!

so let's walk-through two options...

  1. if ZAR is your default currency, then just add NAD to your currencies and give it a "Base Conversion Rate" of 1 - that way, it will shadow ZAR pricing.... you'll get an error on screen, and possibly in the log, when the currency updater runs, but that won't break WHMCS and the other currencies will be updated... and optionally, pricing will be updated too.
  2. if ZAR is NOT your default currency, and for the sake of argument, let's say it's USD, then I would still be tempted to add it... one option would be to add it as ZAR (wouldn't matter if you already have ZAR as a currency), give it the NAD suffix (or whatever prefix it uses)... off the top of my head, the only issue I can think of with this would be any currency selectors in the client area - if you don't have ZAR, then your NAD currency will say ZAR; and if you do have ZAR, then you'll have two different ZAR currencies shown.
    the solution will be a simple hook - but what that hook would look like would depend on your client area theme and where it's showing the currencies... usually with Six and Standard Cart, that would be a sidebar in the cart; with "Modern" it will be flag based; with my header currency option, it will be array based.... the point being that wherever it is, unless you're dong something extraordinarily unusual, i've probably posted a hook previously that can update it.
Link to comment
Share on other sites

1. Yes, this works perfectly in the case where I can set the base currency as ZAR. But I can't for this new whmcs installation where the base currency has to be AUD.

2. ZAR is very volatile. So that is an issue, and the pricing will be weird for australians. 19.24 and 19.35 the next day etc. 

I've added it in the meantime and that means it will work except the price wont get updated. So I'm going to write some script of some kind that automatically updates the NAD price to whatever the ZAR price is. It'll be a super fast and tiny query, so I might even just add it to a hook where it runs on each page load. I.e. Not rely on cron to update it.

Link to comment
Share on other sites

2 hours ago, namhost said:

I've added it in the meantime and that means it will work except the price wont get updated.

you've added it just as NAD ? adding it as ZAR would keep it's prices updated... you'd just have to tweak the currency dropdowns....

with regards to a hook, perhaps the one below will help...

https://developers.whmcs.com/hooks-reference/everything-else/#fetchcurrencyexchangerates

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