gnu-taler-payment-for-woocommerce

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

commit b5e57105e642144168c1a9226eea92374a8e861d
parent 8a7012d22176490b1719a3916d4ee434a9d4fa41
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sun, 14 Sep 2025 11:38:36 +0200

add KUDOS snippet

Diffstat:
Mclass-wc-gnutaler-gateway.php | 6+++---
Asnippets/README.md | 3+++
Asnippets/kudos-currency.php | 46++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 52 insertions(+), 3 deletions(-)

diff --git a/class-wc-gnutaler-gateway.php b/class-wc-gnutaler-gateway.php @@ -242,7 +242,7 @@ function gnutaler_init_gateway_class() { 'title' => __( 'Taler Backend API Key', 'gnutaler' ), 'type' => 'text', 'description' => __( 'Enter your API key to authenticate with the Taler backend. Will be sent as a "Bearer" token using the HTTP "Authorization" header. Must be prefixed with "secret-token:" (RFC 8959). This is not your password but a token to be obtained via the /token endpoint from the REST service.', 'gnutaler' ), - 'default' => 'secret-token:Sandbox ApiKey', + 'default' => 'secret-token:sandbox', ), 'Order_text' => array( 'title' => __( 'Summary Text of the Order', 'gnutaler' ), @@ -807,7 +807,7 @@ function gnutaler_init_gateway_class() { $postcode = $wc_order->get_shipping_postcode ($context = 'view'); if ( is_null( $postcode ) || empty( $postcode ) ) $postcode = $wc_order->get_billing_postcode ($context = 'view'); - + $this->info ( sprintf( 'Shipping address is %s - %s - %s - %s - %s', @@ -816,7 +816,7 @@ function gnutaler_init_gateway_class() { $wc_order->get_shipping_state ($context = 'view'), $wc_order->get_shipping_city ($context = 'view'), $wc_order->get_shipping_postcode ($context = 'view')) ); - + $this->info ( sprintf( 'Billing address is %s - %s - %s - %s - %s', diff --git a/snippets/README.md b/snippets/README.md @@ -0,0 +1,3 @@ +Wordpress snippets for testing: + +- kudos-currency.php: add KUDOS and TESTKUDOS currencies to WooCommerce diff --git a/snippets/kudos-currency.php b/snippets/kudos-currency.php @@ -0,0 +1,46 @@ +/** + * License: Public domain. + * + * Description: Snippets adding support for the KUDOS and TESTKUDOS currency. + * Author Christian Grothoff <grothoff@taler.net> + */ + +// See also https://gist.github.com/woogists/72947b71e48a62f15f5548283d4ed00f#file-wc-add-currency-symbol-php. +add_filter( 'woocommerce_currencies', 'add_my_currency' ); + + +/** + * Extend the list of currencies. + * + * @param array $currencies array with strings with the names of supported currencies. + * + * @return array with extended list of currencies. + */ +function add_my_currency( $currencies ) { + $currencies['KUDOS'] = __( 'KUDOS', 'woocommerce' ); + $currencies['TESTKUDOS'] = __( 'TESTKUDOS', 'woocommerce' ); + return $currencies; +} + + +add_filter( 'woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2 ); + +/** + * Lookup a currency symbol by the given currency. + * + * @param string $currency_symbol Symbol the currency was mapped to so far. + * @param string $currency Currency to map. + * + * @return desired currency symbol, usually the input, except for the two currencies we know. + */ +function add_my_currency_symbol( $currency_symbol, $currency ) { + switch ( $currency ) { + case 'KUDOS': + $currency_symbol = 'ク'; + break; + case 'TESTKUDOS': + $currency_symbol = 'テ'; + break; + } + return $currency_symbol; +}