From ddccebaac6d8b59b5479b0dee478a2daa453c359 Mon Sep 17 00:00:00 2001 From: Anne Mirasol Date: Mon, 23 Dec 2024 15:10:53 -0600 Subject: [PATCH] Avoid resending Processing Order customer email when merchant wins dispute (#3674) * Skip 'Processing Order' customer email on merchant dispute win * Add changelog and readme entries --------- Co-authored-by: Wesley Rosa --- changelog.txt | 1 + includes/class-wc-stripe-webhook-handler.php | 13 +++++++++++++ readme.txt | 1 + 3 files changed, 15 insertions(+) diff --git a/changelog.txt b/changelog.txt index bcb1409a1..f82687838 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,7 @@ *** Changelog *** = 9.1.0 - xxxx-xx-xx = +* Tweak - Avoid re-sending Processing Order customer email when merchant wins dispute. * Fix - Allow the saving of iDEAL tokens when SEPA is disabled. * Fix - Fixes the incompatibility notice in editor due missing style property when instantiating Stripe payment methods. * Dev - Updates the GitHub caching action (`actions/cache`) to v4 due deprecation. diff --git a/includes/class-wc-stripe-webhook-handler.php b/includes/class-wc-stripe-webhook-handler.php index 964bfd8ea..572903a36 100644 --- a/includes/class-wc-stripe-webhook-handler.php +++ b/includes/class-wc-stripe-webhook-handler.php @@ -400,6 +400,19 @@ public function process_webhook_dispute_closed( $notification ) { // Fail order if dispute is lost, or else revert to pre-dispute status. $order_status = 'lost' === $status ? 'failed' : $this->get_stripe_order_status_before_hold( $order ); + + // Do not re-send "Processing Order" email to customer after a dispute win. + if ( 'processing' === $order_status ) { + $emails = WC()->mailer()->get_emails(); + if ( isset( $emails['WC_Email_Customer_Processing_Order'] ) ) { + $callback = [ $emails['WC_Email_Customer_Processing_Order'], 'trigger' ]; + remove_action( + 'woocommerce_order_status_on-hold_to_processing_notification', + $callback + ); + } + } + $order->update_status( $order_status, $message ); } else { $order->add_order_note( $message ); diff --git a/readme.txt b/readme.txt index 6ef7c0000..4c3cf055f 100644 --- a/readme.txt +++ b/readme.txt @@ -111,6 +111,7 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o == Changelog == = 9.1.0 - xxxx-xx-xx = +* Tweak - Avoid re-sending Processing Order customer email when merchant wins dispute. * Fix - Allow the saving of iDEAL tokens when SEPA is disabled. * Fix - Fixes the incompatibility notice in editor due missing style property when instantiating Stripe payment methods. * Dev - Updates the GitHub caching action (`actions/cache`) to v4 due deprecation.