Ensure instructions email is not send on refunds

This commit is contained in:
dinamiko 2022-09-29 16:05:53 +02:00
parent 33bd09e745
commit 950ae2eeb1

View file

@ -258,7 +258,13 @@ class PayUponInvoice {
add_action( add_action(
'woocommerce_email_before_order_table', 'woocommerce_email_before_order_table',
function( WC_Order $order, bool $sent_to_admin ) { 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()}." ); $this->logger->info( "Adding Ratepay payment instructions to email for order #{$order->get_id()}." );
$instructions = $order->get_meta( 'ppcp_ratepay_payment_instructions_payment_reference' ); $instructions = $order->get_meta( 'ppcp_ratepay_payment_instructions_payment_reference' );