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

Do not show deprecated Klarna methods if disabled in Mollie profile #983

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
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
Loading