summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-08-20 11:44:29 +0200
committerChristian Grothoff <christian@grothoff.org>2020-08-20 11:44:29 +0200
commit9d74860a7af15c7be9f997b2454d4d283d002f5d (patch)
treea14bd7f11d3b04583d6cd2dddfc6cd132a91e58f
parentcc0ab6dcb133595d163ef22e5bcc8cc3ad381838 (diff)
downloadwoocommerce-taler-9d74860a7af15c7be9f997b2454d4d283d002f5d.tar.gz
woocommerce-taler-9d74860a7af15c7be9f997b2454d4d283d002f5d.tar.bz2
woocommerce-taler-9d74860a7af15c7be9f997b2454d4d283d002f5d.zip
logo
-rw-r--r--plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php29
1 files changed, 22 insertions, 7 deletions
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 c63b1e0..4eb61ab 100644
--- a/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php
+++ b/plugin/GNU-Taler-Payment-Gateway/class-wc-gnutaler-gateway.php
@@ -113,7 +113,7 @@ function gnutaler_init_gateway_class()
{
$this->id = 'gnutaler'; // payment gateway plugin ID
$this->logger = new WC_logger ($this->id); // setup logging
- $this->icon = $this->plugin_url() . '/assets/images/taler.png';
+ $this->icon = plugins_url ( '/assets/images/taler.png', __FILE__ );
$this->has_fields = false; // We cannot use custom fields to show the QR code / do the wallet integration as WC doesn't give us the order_id at that time. Bummer.
$this->method_title = 'GNU Taler Gateway';
$this->method_description = 'This plugin enables the payment via the GNU Taler payment system'; // will be displayed on the options page
@@ -216,12 +216,15 @@ function gnutaler_init_gateway_class()
return $text;
});
+ // Modify WC canonical refund e-mail notifications to add link to order status page.
+ // (according to https://www.businessbloomer.com/woocommerce-add-extra-content-order-email/)
+ // NOTE: I didn't manage WC to send out ANY e-mail notifications for refunds, so this is
+ // UNTESTED. We do send out our own e-mail on refund below. This is mostly an alternative.
+ add_action( 'woocommerce_email_before_order_table',
+ array ($this, 'add_content_refund_email'),
+ 20,
+ 4 );
- // Add action to modify e-mail consumers receive on refunds with our details.
- // add_filter( 'woocommerce_email_actions', function( $email_actions ) {
- // $email_actions[] = 'class_wc_gnutaler_refund_mail'; // FIXME: what does this do?!?
- // return $email_actions;
- // });
// make sure OIDC 'login' goes to WooCommerce
// (Note: this probably doesn't belong here, but maybe into the
@@ -235,12 +238,24 @@ function gnutaler_init_gateway_class()
$checkout_url = $woocommerce->cart->wc_get_checkout_url ();
wp_redirect( $checkout_url); // or admin_url( $checkout_url) )?;
exit();
- }, 10, 2);
+ },
+ 10,
+ 2);
$user = wp_get_current_user ();
$token_response = $user->get('openid-connect-generic-last-token-response');
}
+ function add_content_refund_email ( $wc_order, $sent_to_admin, $plain_text, $email ) {
+ if ( $email->id == 'customer_refunded_order' ) {
+ $backend_url = $this->get_option( 'GNU_Taler_Backend_URL' );
+ $wc_order_id = $wc_order->get_order_key() . '-' . $wc_order->get_order_number();
+ $refund_url = $backend_url . '/orders/' . $wc_order_id;
+ echo sprintf ( __( 'Refund granted. Visit %s to obtain the refund.'),
+ $refund_url);
+ }
+ }
+
public function payment_fields () {
// We do not have any.
}