diff --git a/src/Gateway/MolliePaymentGateway.php b/src/Gateway/MolliePaymentGateway.php index f71438a8..7cf669eb 100644 --- a/src/Gateway/MolliePaymentGateway.php +++ b/src/Gateway/MolliePaymentGateway.php @@ -30,7 +30,8 @@ class MolliePaymentGateway extends WC_Payment_Gateway implements MolliePaymentGa /** * @var bool */ - protected static $alreadyDisplayedInstructions = false; + protected static $alreadyDisplayedAdminInstructions = false; + protected static $alreadyDisplayedCustomerInstructions = false; /** * Recurring total, zero does not define a recurring total * @@ -115,7 +116,7 @@ public function __construct( $this->paymentFactory = $paymentFactory; $this->pluginId = $pluginId; - // No plugin id, gateway id is unique enough + // No plugin id, gateway id is unique enough $this->plugin_id = ''; // Use gateway class name as gateway id $this->gatewayId(); @@ -156,6 +157,12 @@ public function __construct( 10, 3 ); + add_action( + 'woocommerce_email_order_meta', + [$this, 'displayInstructions'], + 10, + 3 + ); // Adjust title and text on Order Received page in some cases, see issue #166 add_filter('the_title', [$this, 'onOrderReceivedTitle'], 10, 2); @@ -807,7 +814,10 @@ public function displayInstructions( $plain_text = false ) { - if (!$this::$alreadyDisplayedInstructions) { + if ( + ($admin_instructions && !$this::$alreadyDisplayedAdminInstructions) + || (!$admin_instructions && !$this::$alreadyDisplayedCustomerInstructions) + ) { $order_payment_method = $order->get_payment_method(); // Invalid gateway @@ -846,7 +856,12 @@ public function displayInstructions( } } } - $this::$alreadyDisplayedInstructions = true; + if ($admin_instructions && !$this::$alreadyDisplayedAdminInstructions) { + $this::$alreadyDisplayedAdminInstructions = true; + } + if (!$admin_instructions && !$this::$alreadyDisplayedCustomerInstructions) { + $this::$alreadyDisplayedCustomerInstructions = true; + } } /**