Skip to content

Commit

Permalink
Merge pull request #360 from krokedil/develop
Browse files Browse the repository at this point in the history
Version 3.2.3
  • Loading branch information
mntzrr authored Nov 7, 2023
2 parents a68ce1a + 4984fbf commit 94652e7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Blocks/Payment/build/klarna-payments-block.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'fab5fcb2fe4aebd7ff2d');
<?php return array('dependencies' => array(), 'version' => 'dfeaf18c091d3ebcee75');
2 changes: 1 addition & 1 deletion Blocks/Payment/build/klarna-payments-block.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 15 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions klarna-payments-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
* Description: Provides Klarna Payments as payment method to WooCommerce.
* Author: krokedil, klarna, automattic
* Author URI: https://krokedil.com/
* Version: 3.2.2
* Version: 3.2.3
* Text Domain: klarna-payments-for-woocommerce
* Domain Path: /languages
*
* WC requires at least: 5.6.0
* WC tested up to: 8.0.0
* WC tested up to: 8.2.1
*
* Copyright (c) 2017-2023 Krokedil
*
Expand Down Expand Up @@ -39,7 +39,7 @@
/**
* Required minimums and constants
*/
define( 'WC_KLARNA_PAYMENTS_VERSION', '3.2.2' );
define( 'WC_KLARNA_PAYMENTS_VERSION', '3.2.3' );
define( 'WC_KLARNA_PAYMENTS_MIN_PHP_VER', '7.4.0' );
define( 'WC_KLARNA_PAYMENTS_MIN_WC_VER', '5.6.0' );
define( 'WC_KLARNA_PAYMENTS_MAIN_FILE', __FILE__ );
Expand Down
9 changes: 6 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Contributors: klarna, krokedil, automattic
Tags: woocommerce, klarna, ecommerce, e-commerce
Donate link: https://klarna.com
Requires at least: 5.0
Tested up to: 6.2.2
Tested up to: 6.3.2
Requires PHP: 7.4
WC requires at least: 5.6.0
WC tested up to: 8.0.0
Stable tag: 3.2.2
WC tested up to: 8.2.1
Stable tag: 3.2.3
License: GPLv3 or later
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -51,6 +51,9 @@ For help setting up and configuring Klarna Payments for WooCommerce please refer


== Changelog ==
= 2023.11.07 - version 3.2.3 =
* Fix - If Klarna Payment is the preferred payment gateway, the first payment category should be selected by default rather than the last one (current behavior).

= 2023.10.09 - version 3.2.2 =
* Fix - Fixed a critical error due to the class "KP_Api" being undefined.
* Fix - The plugin will no longer cause a critical error when its dependency, WooCommerce, is disabled.
Expand Down
10 changes: 10 additions & 0 deletions templates/klarna-payments-categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
if ( is_array( $payment_categories ) ) {
$available_gateways = WC()->payment_gateways()->get_available_payment_gateways();
$kp = $available_gateways['klarna_payments'];
$chosen_gateway = $available_gateways[ array_key_first( $available_gateways ) ];

foreach ( apply_filters( 'wc_klarna_payments_available_payment_categories', $payment_categories ) as $payment_category ) {
if ( ! is_array( $payment_category ) ) {
Expand All @@ -30,6 +31,15 @@
$kp->id = $payment_category_id;
$kp->title = $payment_category_name;
$kp->icon = $payment_category_icon;

// Make sure the first KP payment categories is selected, if KP is the chosen gateway.
if ( false !== strpos( $chosen_gateway->id, 'klarna_payments' ) || $kp->chosen ) {
$kp->chosen = false;
if ( $payment_category_name == $payment_categories[ array_key_first( $payment_categories ) ]['name'] ) {
$kp->chosen = true;
}
}

wc_get_template( 'checkout/payment-method.php', array( 'gateway' => $kp ) );
}
}

0 comments on commit 94652e7

Please sign in to comment.