Search for keywords, like "PayPal", "Recurring Donations", and more.

Documentation / Developer Docs / Currency Formatting with GiveWP

Currency Formatting with GiveWP

What is Currency Formatting?

GiveWP allows admins to collect donations in a diverse world with over 170 different currencies used worldwide. Everything from the US Dollar to the Japanese Yen. Currencies have their own symbols, but also have different “minor units”. A minor unit is usually referenced as something like “cents”. For example, $1.50 is one dollar and fifty cents. Different currencies have different minor units. The USD, for example, has 2 minor units — meaning it has two decimal places. Most currencies have 2, but some have 3, and others like the Yen have 0.

This doesn’t just stop at what currency is being used, it also has to do with how the number itself is formatted. For example, each of the following represent the same number in different countries:

  • US: $1,250.50
  • DE: 1.250,50 $
  • CA: 1 250,50 $ 

As you can see, the locale — the region of the user — and currency significantly affect how a currency is formatted and how it works. Taking all of this into consideration when displaying a currency to a person is called currency (or number) formatting. The act of adjusting content based on region is called internationalization.

How does GiveWP format currency?

For many years GiveWP has presented Currency settings in the admin side of GiveWP. The admin can define which currency is used, the thousands separator, and so forth. This gives admins the flexibility to adjust the currency formatting for their own region. In the admin side, the numbers would be formatted to approximate the region of the currency. If the currency was the Euro, it would use the common European formatting style.

The problem with all of this is that the currency was, at best, tailoring for a single region, and could quickly lead to confusion. The reality is that many people from all over the world may view your donation form, and it would be best if the currency was formatted to make the most sense to whoever was viewing it. This would apply to both the donation form and the admin side.

For years there wasn’t a better way of handling this. But technology has advanced, internationalization tools have improved, and auto-formatting is possible.

Auto-Formatting Currencies

Modern browsers and servers now have internationalization tools that do the heavy lifting of detecting the number formatting preferences of all the regions in the world, as well as the properties of all those currencies. Furthermore, it is possible to determine a person’s locale when viewing a website.

When you combine all of this, it becomes possible to take any number and automatically format it to fit the preferences of the user. If people visited the same donation form from two places in the world, the numbers would look exactly as they would expect them to.

This is auto-formatting, and it is a very exciting step in an increasingly connected world. Moving forward, GiveWP will be working to make all currencies auto-formatted.

Compatibility

Formatting can happen in two places: in the browser and on the server. These days all modern browsers support internationalization. The preference is to do most formatting in the browser, but sometimes it makes sense to format on the server. This is where there’s a bit of a rub.

WordPress uses a language called PHP on the server in order to run. PHP comes in many versions and has various extensions that add additional functionality. There is one extension in particular called the Intl extension, which provides internationalization.

The problem is that your host — who runs your website — may or may not include the Intl extension in their version of PHP. In GiveWP’s opinion they should, and WordPress itself encourages this in the Site Health tool. We should encourage hosting providers to include the Intl extension to help make this big world more culturally flexible.

In an effort to help alleviate the rub of the Intl extension not being available with some hosting providers, GiveWP added a Currency setting to help.

Setting: Auto-format server currency amounts

You can find the “Auto-format server currency amounts” checkbox by navigating to Donations > Settings > Currency. By default, GiveWP will attempt to detect whether your host has the Intl extension installed. If it does, then this setting will be enabled by default. If not, it will be disabled.

Auto-format server currency amounts is located at Donations > Settings > Currency.

When this setting is enabled, currencies will be auto-formatted on the server. Right now this only affects the admin list tables. When disabled, the server will fall back on the older GiveWP formatting system that uses the currency settings.

Future of Formatting

In the future, the only currency setting in GiveWP will be setting the base currency. All other currency settings will be obsolete, replaced by auto-formatting.

Last updated 1 year ago

Start Fundraising Better Today!

Get GiveWP Today
GiveWP Plans

Give Fundraising Newsletter

The Give Fundraising Newsletter will help you navigate the world of online fundraising like a pro. Each week we send out fundraising advice, Give LIVE announcements, and exclusive offers to our newsletter subscribers.