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

Fix/piwoo-272 banktransfer mail #844

Merged
merged 3 commits into from
Oct 30, 2023
Merged
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
23 changes: 19 additions & 4 deletions src/Gateway/MolliePaymentGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}

/**
Expand Down
Loading