Currency formatting varies from country to country. For example, the placement of a comma (“,”) or period (“.”) in a currency format can mean something completely different depending on what currency is being used. Our core plugin offers formatting for several built-in currencies, which you can specify on the Memberships > Payment Settings page, but what if your currency is not being properly represented?
This code recipe demonstrates how to use the
pmpro_currencies filter to adjust the format to match your desired currency.
About the Code Recipe
A couple of weeks ago, a member from Europe asked us to format the currency for their membership site to prevent any billing confusion. They were based in Denmark, and the core plugin did not include formatting for the Danish Krone.
The code recipe below is an example of how you can change the formatting of your currency from
1 495,00, which is the proper format for Denmark. While this code recipe is specific to the Danish Krone, it demonstrates how to leverage the
pmpro_currencies filter and can be altered to suit your needs.
If you are looking to add a new default currency to your membership site, have a look at this article which further explains the filter.
The Code Recipe
Adding the Recipe to Your Website
You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.