From 7582955791fa9a720852bba7288544c55444fa70 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 4 Sep 2020 00:07:01 +0200 Subject: find a better place for OIDC/WooCommerce integration: snipptes --- .../class-wc-gnutaler-gateway.php | 27 ++-------------------- .../KUDOS-WooCommerce-Support.php.txt | 21 ----------------- server-build/QEMU-autobuild/buildWebstore.sh | 18 +++++++++++++-- snippets/kudos-currency.php | 21 +++++++++++++++++ snippets/oidc-reclaim.php | 23 ++++++++++++++++++ 5 files changed, 62 insertions(+), 48 deletions(-) delete mode 100644 server-build/QEMU-autobuild/KUDOS-WooCommerce-Support.php.txt create mode 100644 snippets/kudos-currency.php create mode 100644 snippets/oidc-reclaim.php diff --git a/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php b/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php index 9662477..011e209 100644 --- a/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php +++ b/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php @@ -42,13 +42,10 @@ define("MERCHANT_PROTOCOL_AGE", 0); /* -TODO (with FIXME in code): -- figure out where OIDC logic should go - -TODO (without FIXME in code): +TODO: - refund needs to be tested more (with wallet!) -FEATURES: +OPEN FEATURES: - MAYBE: multi-currency support (i.e. use https://$CURRENCY.$backend_url/?) */ @@ -220,26 +217,6 @@ function gnutaler_init_gateway_class() 20, 4 ); - // Modify OIDC connect button text for Reclaim:ID - // (FIXME: this probably doesn't belong here!) - add_filter('openid-connect-generic-login-button-text', function( $text ) { - $text = __('Login with Re:ClaimID', 'gnutaler' ); - return $text; - }); - - // make sure OIDC 'login' goes to WooCommerce - // (FIXME: this probably doesn't belong here, but maybe into the - // OIDC button hook for WC!?) - add_action('openid-connect-generic-redirect-user-back', - function( $redirect_url, $user ) { - // Take over the redirection complete. Send users somewhere special based on their capabilities. - global $woocommerce; - $checkout_url = $woocommerce->cart->wc_get_checkout_url (); - wp_redirect( $checkout_url); // or admin_url( $checkout_url) )?; - exit(); - }, - 10, - 2); } /** diff --git a/server-build/QEMU-autobuild/KUDOS-WooCommerce-Support.php.txt b/server-build/QEMU-autobuild/KUDOS-WooCommerce-Support.php.txt deleted file mode 100644 index 0ddcb3f..0000000 --- a/server-build/QEMU-autobuild/KUDOS-WooCommerce-Support.php.txt +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Support for the KUDOS and TESTKUDOS currency. This goes into functions.php - * https://gist.github.com/woogists/72947b71e48a62f15f5548283d4ed00f#file-wc-add-currency-symbol-php - */ -add_filter( 'woocommerce_currencies', 'add_my_currency' ); - -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); - -function add_my_currency_symbol( $currency_symbol, $currency ) { - switch( $currency ) { - case 'KUDOS': $currency_symbol = 'ク'; break; - case 'TESTKUDOS': $currency_symbol = 'テ'; break; - } - return $currency_symbol; -} diff --git a/server-build/QEMU-autobuild/buildWebstore.sh b/server-build/QEMU-autobuild/buildWebstore.sh index a28fba5..e47884e 100755 --- a/server-build/QEMU-autobuild/buildWebstore.sh +++ b/server-build/QEMU-autobuild/buildWebstore.sh @@ -167,12 +167,26 @@ sudo -u www-data wp media import https://live.staticflickr.com/7199/6929220523_1 # Add Snippet to enable KUDOS currency in WooCommerce # Note: this will break the shop badly if run twice, # recovery by deleting the duplicate entries! -SNIPPET=`cat ${ORIGIN}/woocommerce-taler/server-build/QEMU-autobuild/KUDOS-WooCommerce-Support.php.txt` +SNIPPET=`cat ${ORIGIN}/woocommerce-taler/snippets/kudos-currency.php` cat | mysql wordpress <cart->wc_get_checkout_url (); + wp_redirect( $checkout_url); // or admin_url( $checkout_url) )?; + exit(); + }, + 10, + 2); -- cgit v1.2.3