Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimwhite/909eef03ea89ff65f65ed0e8a639f31e to your computer and use it in GitHub Desktop.
Save kimwhite/909eef03ea89ff65f65ed0e8a639f31e to your computer and use it in GitHub Desktop.
Change the display format of a price. This example will change the price format display to a Hungary format.
<?php
/**
* Change the display format of a price for a specific currency.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_huf_price_format( $formatted, $price, $pmpro_currency, $pmpro_currency_symbol ) {
// Let's only do this for our specific currency
if ( 'HUF' === $pmpro_currency ) {
// Let's customize the display of the price
$new_price = number_format($price, 3, '.', ' ');
// Let's add the currency symbol as a postfix
$formatted = $new_price . ' ' . $pmpro_currency_symbol;
}
return $formatted;
}
add_filter( 'pmpro_format_price', 'my_pmpro_huf_price_format', 20, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment