Skip to content

Commit

Permalink
Add details to customer email
Browse files Browse the repository at this point in the history
  • Loading branch information
mmaymo committed Oct 17, 2023
1 parent e070103 commit b686086
Showing 1 changed file with 28 additions and 15 deletions.
43 changes: 28 additions & 15 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 @@ -267,17 +274,17 @@ public function isValidForUse(): bool
$test_mode = $this->dataService->isTestModeEnabled();

$this->errors[] = ($test_mode ? __(
'Test mode enabled.',
'mollie-payments-for-woocommerce'
) . ' ' : '') . sprintf(
'Test mode enabled.',
'mollie-payments-for-woocommerce'
) . ' ' : '') . sprintf(
/* translators: The surrounding %s's Will be replaced by a link to the global setting page */
__(
'No API key provided. Please %1$sset you Mollie API key%2$s first.',
'mollie-payments-for-woocommerce'
),
'<a href="' . $this->dataService->getGlobalSettingsUrl() . '">',
'</a>'
);
__(
'No API key provided. Please %1$sset you Mollie API key%2$s first.',
'mollie-payments-for-woocommerce'
),
'<a href="' . $this->dataService->getGlobalSettingsUrl() . '">',
'</a>'
);

return false;
}
Expand Down Expand Up @@ -806,8 +813,9 @@ public function displayInstructions(
$admin_instructions = false,
$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 +854,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

0 comments on commit b686086

Please sign in to comment.