gnu-taler-payment-for-woocommerce

WooCommerce plugin to enable payments with GNU Taler
Log | Files | Refs | LICENSE

kudos-currency.php (1318B)


      1 <?php
      2 
      3 /**
      4  * License: Public domain.
      5  *
      6  * Description: Snippets adding support for the KUDOS and TESTKUDOS currency.
      7  * Author Christian Grothoff <grothoff@taler.net>
      8  */
      9 
     10 // See also https://gist.github.com/woogists/72947b71e48a62f15f5548283d4ed00f#file-wc-add-currency-symbol-php.
     11 add_filter( 'woocommerce_currencies', 'add_my_currency' );
     12 
     13 
     14 /**
     15  * Extend the list of currencies.
     16  *
     17  * @param array $currencies array with strings with the names of supported currencies.
     18  *
     19  * @return array with extended list of currencies.
     20  */
     21 function add_my_currency( $currencies ) {
     22 	$currencies['KUDOS']     = __( 'KUDOS', 'woocommerce' );
     23 	$currencies['TESTKUDOS'] = __( 'TESTKUDOS', 'woocommerce' );
     24 	return $currencies;
     25 }
     26 
     27 
     28 add_filter( 'woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2 );
     29 
     30 /**
     31  * Lookup a currency symbol by the given currency.
     32  *
     33  * @param string $currency_symbol Symbol the currency was mapped to so far.
     34  * @param string $currency        Currency to map.
     35  *
     36  * @return desired currency symbol, usually the input, except for the two currencies we know.
     37  */
     38 function add_my_currency_symbol( $currency_symbol, $currency ) {
     39 	switch ( $currency ) {
     40 		case 'KUDOS':
     41 			$currency_symbol = 'ク';
     42 			break;
     43 		case 'TESTKUDOS':
     44 			$currency_symbol = 'テ';
     45 			break;
     46 	}
     47 	return $currency_symbol;
     48 }