PHP warning in country_currency_check() | WordPress.org

[ad_1]

Current implementation in klarna-payments-for-woocommerce/classes/class-wc-gateway-klarna-payments.php in WC_Gateway_Klarna_Payments::country_currency_check at line 230 has a flaw:

$klarna_country = kp_get_klarna_country( $order );
$country = strtolower( $klarna_country );
$country_values = KP_Form_Fields::$kp_form_auto_countries[ $country ];

if ( ! isset( KP_Form_Fields::$kp_form_auto_countries[ $country ] ) ) {
kp_unset_session_values();
return new WP_Error( 'country', "Country ({$country}) is not supported by Klarna Payments." );
}

You are trying to access array value by key (highlighted in bold) first and then do isset() check and exit the function if it’s not found. Unfortunately this generates a PHP warning for undefined array key every time this method is called.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer