Skip to content

Instantly share code, notes, and snippets.

@NiklasHogefjord
Created October 7, 2015 15:03
Show Gist options
  • Save NiklasHogefjord/1c2fcc9fc681ba1e1a13 to your computer and use it in GitHub Desktop.
Save NiklasHogefjord/1c2fcc9fc681ba1e1a13 to your computer and use it in GitHub Desktop.
Klarna for WooCommerce - Filter Create order object sent to Klarna for disabling autofocus of email field
/**
* WooCommerce - Klarna payment gateway
* Filter Create order for disabling autofocus of email field.
**/
// New order ($create)
add_filter('kco_create_order', 'my_kco_create_order');
function my_kco_create_order( $create ) {
$create['gui']['options'] = array('disable_autofocus');
return $create;
}
@yratof
Copy link

yratof commented Dec 9, 2015

Have you managed to get this working with Klarna Checkout? Doesn't seem to listen to it, especially on mobile, focus kicks in and shoots the page down to the bottom of the site. Missing all the information.

@breadadams
Copy link

breadadams commented Oct 20, 2017

You need to change line 7 to:

add_action('kco_create_order', 'my_kco_create_order');

With that change, it's working for me on latest version of WooCommerce & the woocommerce-gateway-klarna plugin.

Updated gist

@SirRahikkala
Copy link

Sorry, should this work with adding the those lines to functions.php? with the modified line 7 for WooCommerce Klarna Gateway 2.5.11 it still focuses to form.
https://github.com/woocommerce/woocommerce-gateway-klarna

@orjansteffensen
Copy link

Received this snippet from Krokedil which worked for me

/**
* WooCommerce - Klarna payment gateway
* Filter Create order for disabling autofocus of email field.
**/
// New order ($create)
add_filter('kco_wc_create_order', 'my_kco_create_order');
function my_kco_create_order( $create ) {
$create['gui']['options'] = array('disable_autofocus');
return $create;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment