Forked from ipokkel/french-canadian-price-format.php
Last active
March 27, 2024 15:22
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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