From 950ae2eeb1cd3bddd4eb4077ffe680068fe1a29d Mon Sep 17 00:00:00 2001 From: dinamiko Date: Thu, 29 Sep 2022 16:05:53 +0200 Subject: [PATCH] Ensure instructions email is not send on refunds --- .../src/Gateway/PayUponInvoice/PayUponInvoice.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php index 2529afad4..1b16a11d6 100644 --- a/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php +++ b/modules/ppcp-wc-gateway/src/Gateway/PayUponInvoice/PayUponInvoice.php @@ -258,7 +258,13 @@ class PayUponInvoice { add_action( 'woocommerce_email_before_order_table', function( WC_Order $order, bool $sent_to_admin ) { - if ( ! $sent_to_admin && PayUponInvoiceGateway::ID === $order->get_payment_method() && $order->has_status( 'processing' ) ) { + $action = filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRING ) ?? ''; + if ( + ! $sent_to_admin + && PayUponInvoiceGateway::ID === $order->get_payment_method() + && $order->has_status( 'processing' ) + && ( $action && $action !== 'woocommerce_refund_line_items' ) + ) { $this->logger->info( "Adding Ratepay payment instructions to email for order #{$order->get_id()}." ); $instructions = $order->get_meta( 'ppcp_ratepay_payment_instructions_payment_reference' );