Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NiklasHogefjord/1433d99b1b001b97662834d821088076 to your computer and use it in GitHub Desktop.
Save NiklasHogefjord/1433d99b1b001b97662834d821088076 to your computer and use it in GitHub Desktop.
Filter country sent to Klarna to modify which checkout iframe should be displayed for the customer. This could be useful when selling to multiple Euro-countries (Finland, Germany, Netherlands, Austria) and have a separate plugin for the customer so select their shipping country (or have Geo location enabled). In this case you don't have to use t…
<?php
/**
* WooCommerce - Klarna payment gateway
* Filter the country sent to Klarna.
**/
add_filter( 'klarna_country', 'my_klarna_country' );
function my_klarna_country( $country ) {
if( WC()->customer ) {
if ( 'EUR' == get_woocommerce_currency() ) {
if( WC()->customer->shipping_country ) {
$country = WC()->customer->shipping_country;
}
}
}
return $country;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment