Back to Blog Posts

WHMCS Insights: Adding Custom Currency Flags

By John / December 15th, 2014

Our Modern and Slider order form templates in WHMCS version 5.x have a neat little system of flags which allow new signups to easily switch the order process into their local currency. We often receive support tickets asking how to add flags for a whole range of additional currencies, so thought I'd take some time to share how one would achieve that.


WHMCS has flags for the following currencies as standard; AUD, CAD, EUR, GBP, INR, JPY, USD and ZAR. If any of these currencies are configured, a flag will appear on the shopping cart for new signups to select as shown above. In this example I will be adding Chinese Yuan (CNY) and modifying the Modern template, but you can also follow this same technique with the Slider template.

So to add flags for more currencies, first obtain or create a flag image measuring 16px by 11px and then upload it to the /images/flags directory.

Next we need to copy the order form template to give us one we can customise. So duplicate the /templates/orderforms/modern directory and name it whatever you like, for this example I will call it 'moderncustom'.

Open /templates/orderforms/moderncustom/products.tpl and look for line 26:

{elseif $curr.code eq "EUR"}eu
{elseif $curr.code eq "GBP"}gb
{elseif $curr.code eq "INR"}in
{elseif $curr.code eq "JPY"}jp
{elseif $curr.code eq "USD"}us
{elseif $curr.code eq "ZAR"}za
{else}na{/if}.png" border="0" alt="" /> {$curr.code}


Replace it with:

{elseif $curr.code eq "EUR"}eu
{elseif $curr.code eq "GBP"}gb
{elseif $curr.code eq "INR"}in
{elseif $curr.code eq "JPY"}jp
{elseif $curr.code eq "USD"}us
{elseif $curr.code eq "ZAR"}za
{elseif $curr.code eq "CNY"}ch
{else}na{/if}.png" border="0" alt="" /> {$curr.code}


Where my flag image is called ch.png. I've highlighted the code added in the screenshot below. The end result is a block of code on line 26 which looks like:


Next open /templates/orderforms/moderncustom/viewcart.tpl and made the exact same modification to line 47 of this file too.

Now upload the two templates files we just edited. Login to your WHMCS admin area to select the moderncustom order form template from the Setup > General Settings > Ordering tab and you're done!

A flag image will now be displayed to visitors on the order form next to the CNY currency option. It would just be a case of adjusting the "CNY" variable and "ch" filename in order to add as many different flags as desired.

Liked this article? Share it