Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent sending shopper emails when disputes are closed #8308

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/fix-7928-prevent-sending-order-complete-emails
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: fix

Order completed and refunded emails are no longer sent when a dispute is closed.
8 changes: 8 additions & 0 deletions includes/class-wc-payments-order-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,10 @@ public function mark_payment_dispute_closed( $order, $charge_id, $status ) {
return;
}

// Order `completed` and `refunded` emails should both be blocked when disputes are closed.
add_filter( 'woocommerce_email_enabled_customer_completed_order', '__return_false' );
add_filter( 'woocommerce_email_enabled_customer_refunded_order', '__return_false' );
Comment on lines +349 to +350
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered only adding the specific filters inside the if, but it seemed more readable to me to add and remove both at the same time.


if ( 'lost' === $status ) {
wc_create_refund(
[
Expand All @@ -360,6 +364,10 @@ public function mark_payment_dispute_closed( $order, $charge_id, $status ) {
$order->save();
}

// Restore completed and refunded order emails.
remove_filter( 'woocommerce_email_enabled_customer_completed_order', '__return_false' );
remove_filter( 'woocommerce_email_enabled_customer_refunded_order', '__return_false' );

$order->add_order_note( $note );
}

Expand Down
Loading