Change a currency symbol
This commit is contained in:
parent
cb2cf79342
commit
0b48931d11
|
@ -4,4 +4,5 @@ Various code snippets you can add to your site to enable custom functionality:
|
||||||
|
|
||||||
- [Add a message above the login / register form](./before-login--register-form.md)
|
- [Add a message above the login / register form](./before-login--register-form.md)
|
||||||
- [Change number of related products output](./number-of-products-per-row.md)
|
- [Change number of related products output](./number-of-products-per-row.md)
|
||||||
|
- [Change a currency symbol](./change-a-currency-symbol.md)
|
||||||
- [Unhook and remove WooCommerce emails](./unhook--remove-woocommerce-emails.md)
|
- [Unhook and remove WooCommerce emails](./unhook--remove-woocommerce-emails.md)
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Rename a country
|
||||||
|
|
||||||
|
See the [currency list](https://woocommerce.github.io/code-reference/files/woocommerce-includes-wc-core-functions.html#source-view.475) for reference on currency codes.
|
||||||
|
|
||||||
|
|
||||||
|
> This is a **Developer level** doc. If you are unfamiliar with code and resolving potential conflicts, select a [WooExpert or Developer](https://woocommerce.com/customizations/) for assistance. We are unable to provide support for customizations under our [Support Policy](http://www.woocommerce.com/support-policy/).
|
||||||
|
|
||||||
|
Add this code to your child theme’s `functions.php` file or via a plugin that allows custom functions to be added, such as the [Code Snippets](https://wordpress.org/plugins/code-snippets/) plugin. Avoid adding custom code directly to your parent theme’s functions.php file, as this will be wiped entirely when you update the theme.
|
||||||
|
|
||||||
|
```php
|
||||||
|
if ( ! function_exists( 'YOUR_PREFIX_change_currency_symbol' ) ) {
|
||||||
|
/**
|
||||||
|
* Change a currency symbol
|
||||||
|
*
|
||||||
|
* @param string $currency_symbol Existing currency symbols.
|
||||||
|
* @param string $currency Currency code.
|
||||||
|
* @return string $currency_symbol Updated currency symbol(s).
|
||||||
|
*/
|
||||||
|
function YOUR_PREFIX_change_currency_symbol( $currency_symbol, $currency ) {
|
||||||
|
switch( $currency ) {
|
||||||
|
case 'AUD': $currency_symbol = 'AUD$'; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $currency_symbol;
|
||||||
|
}
|
||||||
|
add_filter( 'woocommerce_currency_symbol', 'YOUR_PREFIX_change_currency_symbol', 10, 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
Loading…
Reference in New Issue