Skip to content

Commit

Permalink
Merge branch 'develop' into develop-block-support-twentytwenty
Browse files Browse the repository at this point in the history
  • Loading branch information
anyakro authored Nov 20, 2024
2 parents 0a03009 + 24c3a99 commit 59320b4
Show file tree
Hide file tree
Showing 18 changed files with 7,061 additions and 19,777 deletions.
1 change: 1 addition & 0 deletions assets/css/checkout-addons.min.css

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

1 change: 1 addition & 0 deletions assets/css/klarna-express-button.min.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
klarna-express-button{margin-bottom:1em}@media (max-width:500px){#klarna-express-button-0{width:100%}}
4 changes: 2 additions & 2 deletions assets/css/klarna-payments-admin.css
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
@font-face {
font-family: Klarna;
font-weight: 300;
src: url("../fonts/KlarnaSans-Regular.otf") format("opentype");
src: url("../fonts/KlarnaText-Regular.otf") format("opentype");
}

@font-face {
font-family: KlarnaHeadline;
font-weight: bold;
src: url("../fonts/KlarnaHeadline-Bold.otf") format("opentype");
src: url("../fonts/KlarnaText-Bold.otf") format("opentype");
}

/** New Settings page styling */
Expand Down
1 change: 1 addition & 0 deletions assets/css/klarna-payments-admin.min.css

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

Binary file removed assets/fonts/KlarnaHeadline-Bold.otf
Binary file not shown.
Binary file removed assets/fonts/KlarnaSans-Regular.otf
Binary file not shown.
Binary file added assets/fonts/KlarnaText-Bold.otf
Binary file not shown.
Binary file added assets/fonts/KlarnaText-Regular.otf
Binary file not shown.
12 changes: 6 additions & 6 deletions classes/admin/class-kp-form-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public static function get_credential_section_fields( $settings = array() ) {
),
'testmode' => array(
'title' => __( 'Test mode', 'klarna-payments-for-woocommerce' ),
'label' => __( 'Enable Klarna Payments in Klarna\'s test environment.', 'klarna-payments-for-woocommerce' ),
'label' => __( 'Enable Klarna in Klarna\'s test environment.', 'klarna-payments-for-woocommerce' ),
'type' => 'checkbox',
'default' => 'no',
'desc_tip' => true,
Expand Down Expand Up @@ -327,7 +327,7 @@ public static function get_kp_section_fields( $settings = array() ) {
$kp_section = array(
'general' => array(
'id' => 'general',
'title' => 'Klarna Payments*',
'title' => 'Klarna Payments',
'description' => __( 'Give your customers the ability to pay in flexible ways such as Buy now, Pay Later, Invoicing, Installments and Financing.', 'klarna-payments-for-woocommerce' ),
'links' => array(
array(
Expand Down Expand Up @@ -385,9 +385,9 @@ public static function get_kp_section_fields( $settings = array() ) {
'desc_tip' => true,
),
'add_to_email' => array(
'title' => __( 'Add Klarna Urls to order email', 'klarna-payments-for-woocommerce' ),
'title' => __( 'Add Klarna URLs to order email', 'klarna-payments-for-woocommerce' ),
'type' => 'checkbox',
'label' => __( 'This will add Klarna urls to the order emails that are sent. You can read more about this here: ', 'klarna-payments-for-woocommerce' ) . '<a href="https://docs.klarna.com/payments/web-payments/additional-resources/ux-guidelines/post-purchase-experience/" target="_blank">Klarna URLs</a>',
'label' => __( 'This will add Klarna URLs to the order emails that are sent. You can read more about this here: ', 'klarna-payments-for-woocommerce' ) . '<a href="https://docs.klarna.com/payments/web-payments/additional-resources/ux-guidelines/post-purchase-experience/" target="_blank">Klarna URLs</a>',
'default' => 'no',
'desc_tip' => false,
),
Expand All @@ -397,8 +397,8 @@ public static function get_kp_section_fields( $settings = array() ) {
'label' => __( 'Customer type', 'klarna-payments-for-woocommerce' ),
'description' => __( 'Select the customer for the store.', 'klarna-payments-for-woocommerce' ),
'options' => array(
'b2c' => __( 'B2C', 'klarna-payments-for-woocommerce' ),
'b2b' => __( 'B2B', 'klarna-payments-for-woocommerce' ),
'b2c' => __( 'Business to Consumer (B2C)', 'klarna-payments-for-woocommerce' ),
'b2b' => __( 'Business to Business (B2B)', 'klarna-payments-for-woocommerce' ),
),
'default' => 'b2c',
'desc_tip' => true,
Expand Down
4 changes: 2 additions & 2 deletions classes/admin/class-kp-settings-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public function preload_fonts() {
}

?>
<link rel="preload" href="<?php echo esc_url( WC_KLARNA_PAYMENTS_PLUGIN_URL ); ?>/assets/fonts/KlarnaSans-Regular.otf" as="font" type="font/otf" crossorigin>
<link rel="preload" href="<?php echo esc_url( WC_KLARNA_PAYMENTS_PLUGIN_URL ); ?>/assets/fonts/KlarnaHeadline-Bold.otf" as="font" type="font/otf" crossorigin>
<link rel="preload" href="<?php echo esc_url( WC_KLARNA_PAYMENTS_PLUGIN_URL ); ?>/assets/fonts/KlarnaText-Regular.otf" as="font" type="font/otf" crossorigin>
<link rel="preload" href="<?php echo esc_url( WC_KLARNA_PAYMENTS_PLUGIN_URL ); ?>/assets/fonts/KlarnaText-Bold.otf" as="font" type="font/otf" crossorigin>
<?php
}

Expand Down
16 changes: 13 additions & 3 deletions classes/class-kp-session.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class KP_Session {
*/
public $session_country = null;

/**
* Get the locale used for the Klarna session.
*
* @var string
*/
public $session_locale = null;

/**
* Class constructor.
*/
Expand Down Expand Up @@ -79,11 +86,12 @@ public function get_session( $order = null ) {
// Set session data from WC Session or order meta if we have any.
$this->set_session_data( $order );

// If we already have a Klarna session, and the session_country has changed since our last request, reset all our params and a new session will be created.
if ( null !== $this->klarna_session && kp_get_klarna_country( $order ) !== $this->session_country ) {
// If we already have a Klarna session, and the session_country or session_locale has changed since our last request, reset all our params and a new session will be created.
if ( null !== $this->klarna_session && ( kp_get_klarna_country( $order ) !== $this->session_country || get_locale() !== $this->session_locale ) ) {
$this->klarna_session = null;
$this->session_hash = null;
$this->session_country = null;
$this->session_locale = null;
}

// If we already have a Klarna session and session does not need an update, return the Klarna session.
Expand Down Expand Up @@ -139,6 +147,7 @@ public function set_session_data( $order = null ) {
$this->klarna_session = $session_data['klarna_session'];
$this->session_hash = $session_data['session_hash'];
$this->session_country = $session_data['session_country'];
$this->session_locale = $session_data['session_locale'];
}

/**
Expand All @@ -158,6 +167,7 @@ private function process_result( $result, $order ) {
$this->klarna_session = ! empty( $result ) ? $result : $this->klarna_session; // If the result is empty, it was from a successfull update request. So no need to update the session data.
$this->session_hash = null === $order ? $this->get_session_cart_hash() : $this->get_session_order_hash( $order );
$this->session_country = kp_get_klarna_country( $order );
$this->session_locale = get_locale();

// Update the WC Session or the order meta with instance of class.
$this->update_session_data_in_wc( $order );
Expand Down Expand Up @@ -256,7 +266,7 @@ private function get_session_cart_hash() {
// The `get_totals` method can return non-numeric items which should be removed before using `array_sum`.
$cart_totals = array_filter(
WC()->cart->get_totals(),
function( $total ) {
function ( $total ) {
return is_numeric( $total );
}
);
Expand Down
32 changes: 32 additions & 0 deletions gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-wp-i18n');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.initConfig({
makepot: {
target: {
options: {
domainPath: '/languages',
mainFile: 'klarna-payments-for-woocommerce',
potFilename: 'klarna-payments-for-woocommerce.pot',
processPot(pot, options) {
// add header options
return pot;
},
type: 'wp-plugin',
},
},
},
// minify css
cssmin: {
target: {
files: [{
expand: true,
cwd: './assets/css',
src: ['*.css', '!*.min.css'],
dest: './assets/css',
ext: '.min.css',
}],
},
}
});
};
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: klarna
* Author URI: https://www.klarna.com/
* Version: 3.8.1
* Version: 3.8.3
* Text Domain: klarna-payments-for-woocommerce
* Domain Path: /languages
*
* WC requires at least: 5.6.0
* WC tested up to: 9.3.1
* WC tested up to: 9.4.0
* Requires Plugins: woocommerce
*
* Copyright (c) 2017-2024 Krokedil
Expand Down Expand Up @@ -43,7 +43,7 @@
/**
* Required minimums and constants
*/
define( 'WC_KLARNA_PAYMENTS_VERSION', '3.8.1' );
define( 'WC_KLARNA_PAYMENTS_VERSION', '3.8.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
Loading

0 comments on commit 59320b4

Please sign in to comment.