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 ipokkel/a1ba7c5ebf1a489bfeeab2f5507c2f6f to your computer and use it in GitHub Desktop.
Save ipokkel/a1ba7c5ebf1a489bfeeab2f5507c2f6f to your computer and use it in GitHub Desktop.
Change "$" to "US$" for the PMPro US Dollar currency symbol.
<?php
/**
* Add "US" as a prefix to "$" for the US Dollar currency code ("US$").
*
* 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/
*/
/**
* This function changes the values of specific keys for a currency in the `$pmpro_currencies` array.
*
* @link https://github.com/strangerstudios/paid-memberships-pro/blob/dev/includes/currencies.php
*
* @param array $pmpro_currencies The currency array created by PMPro
* @return array The adjusted currency array
*/
function my_pmpro_customize_us_dollar_currency( $pmpro_currencies ) {
$pmpro_currencies['USD'] = array(
'name' => __( 'US Dollars (&#36;)', 'paid-memberships-pro' ),
'decimals' => '2',
'thousands_separator' => ',',
'decimal_separator' => '.',
'symbol' => 'US&#36;', // e.g. US$25.00
'position' => 'left',
);
return $pmpro_currencies;
}
add_filter( 'pmpro_currencies', 'my_pmpro_customize_us_dollar_currency' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment