Use wc email id to ensure customer is processing order

This commit is contained in:
dinamiko 2022-09-30 11:13:52 +02:00
parent 950ae2eeb1
commit c013db5526

View file

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice; namespace WooCommerce\PayPalCommerce\WcGateway\Gateway\PayUponInvoice;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use WC_Email;
use WC_Order; use WC_Order;
use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PayUponInvoiceOrderEndpoint; use WooCommerce\PayPalCommerce\ApiClient\Endpoint\PayUponInvoiceOrderEndpoint;
use WooCommerce\PayPalCommerce\ApiClient\Factory\CaptureFactory; use WooCommerce\PayPalCommerce\ApiClient\Factory\CaptureFactory;
@ -257,13 +258,12 @@ 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, bool $plain_text, WC_Email $email ) {
$action = filter_input( INPUT_POST, 'action', FILTER_SANITIZE_STRING ) ?? '';
if ( if (
! $sent_to_admin ! $sent_to_admin
&& PayUponInvoiceGateway::ID === $order->get_payment_method() && PayUponInvoiceGateway::ID === $order->get_payment_method()
&& $order->has_status( 'processing' ) && $order->has_status( 'processing' )
&& ( $action && $action !== 'woocommerce_refund_line_items' ) && $email->id === 'customer_processing_order'
) { ) {
$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()}." );
@ -315,7 +315,7 @@ class PayUponInvoice {
} }
}, },
10, 10,
2 4
); );
add_filter( add_filter(