Created
November 16, 2020 02:33
-
-
Save DeveloperWil/7439b126a46442d840e394e195acbc58 to your computer and use it in GitHub Desktop.
WooCommerce: Add A Custom Currency Label, Description and Symbol
This file contains hidden or 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
| /** | |
| * Add custom currency label to WooCommerce | |
| * | |
| * @author Wil Brown zeropointdevelopment.com | |
| * @param $currencies | |
| * @return mixed | |
| */ | |
| function zpd_add_wc_currency( $currencies ) { | |
| $currencies['BANANA'] = __( 'Banana', 'woocommerce' ); | |
| return $currencies; | |
| } | |
| add_filter( 'woocommerce_currencies', 'zpd_add_wc_currency' ); | |
| /** | |
| * Add custom currency symbol to new currency label. | |
| * | |
| * @author Wil Brown zeropointdevelopment.com | |
| * @param $currency_symbol | |
| * @param $currency | |
| * @return string | |
| */ | |
| function zpd_add_wc_currency_symbol( $currency_symbol, $currency ) { | |
| switch( $currency ) { | |
| case 'BANANA': $currency_symbol = '🍌'; | |
| break; | |
| } | |
| return $currency_symbol; | |
| } | |
| add_filter('woocommerce_currency_symbol', 'zpd_add_wc_currency_symbol', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment