Skip to content

Commit

Permalink
Merge pull request #983 from mollie/PIWOO-565-do-not-show-deprecated-…
Browse files Browse the repository at this point in the history
…klarna-methods-if-disabled-in-mollie-profile

Do not show deprecated Klarna methods if disabled in Mollie profile
  • Loading branch information
danielhuesken authored Jan 31, 2025
2 parents 523176c + 1455736 commit 5b5506a
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Settings/Page/Section/PaymentMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public function renderGateways(): string
'mollie-payments-for-woocommerce'
);
$descriptionActivePaymentMethods = __(
'These payment methods are active in your Mollie profile.
'These payment methods are active in your Mollie profile.
You can enable these payment methods in their settings to make them available for your customers.',
'mollie-payments-for-woocommerce'
);
$titleInactivePaymentMethods = __('Inactive Payment Methods', 'mollie-payments-for-woocommerce');
$descriptionInactivePaymentMethods = __(
'These payment methods are available in your Mollie profile but are
'These payment methods are available in your Mollie profile but are
not currently active. Activate them to offer more payment options to your customers.',
'mollie-payments-for-woocommerce'
);
Expand All @@ -61,6 +61,13 @@ public function renderGateways(): string
$gatewayKey = 'mollie_wc_gateway_' . $paymentMethodId;
$enabledInMollie = array_key_exists($gatewayKey, $this->mollieGateways);

//don't display old klarna GWs
if (isset($this->paymentMethods['klarna']) && in_array($paymentMethodId, ['klarnasliceit', 'klarnapaylater', 'klarnapaynow'], true)) {
if (!$enabledInMollie) {
continue;
}
}

$paymentGatewayButton = $this->paymentGatewayButton($paymentMethod, $enabledInMollie);
if ($enabledInMollie) {
$activatedGateways .= $paymentGatewayButton;
Expand Down Expand Up @@ -88,7 +95,7 @@ protected function paymentGatewaysBlock(string $title, string $description, stri
<h3><?= esc_html($title); ?></h3>
<p><?= esc_html($description); ?></p>
<div class="mollie-settings-pm__list">
<?= $html; // WPCS: XSS ok. ?>
<?= $html; // phpcs:ignore XSS ok. ?>
</div>
</div>
<?php
Expand Down Expand Up @@ -232,10 +239,10 @@ protected function paymentGatewayButton(AbstractPaymentMethod $paymentMethod, $e
ob_start();
?>
<div class="mollie-settings-pm__single">
<?= $paymentMethod->getIconUrl(); // WPCS: XSS ok.?>
<?= $paymentMethod->getIconUrl(); // phpcs:ignore XSS ok.?>
<?= esc_html($paymentMethod->title());?>
<?= $messageOrLink; // WPCS: XSS ok.?>
<?= $button; // WPCS: XSS ok.?>
<?= $messageOrLink; // phpcs:ignore XSS ok.?>
<?= $button; // phpcs:ignore XSS ok.?>
</div>
<?php
return ob_get_clean();
Expand Down

0 comments on commit 5b5506a

Please sign in to comment.