Klarna Checkout – Hooks (action & filter)

Hooks in WordPress essentially allow you to change or add code without editing core files. They are used extensively throughout WordPress and WooCommerce and are very useful for developers.

Read more about action and filter hooks here:
In Klarna Checkout for WooCommerce there are some action and filter hooks available, mainly for modifying the order data sent to Klarna and how the checkout page should be displayed.


The appearance of the Klarna Checkout page comes with a two-column layout. In this layout we have shopping cart, delivery options and customer order note in the left-hand column while Klarna’s checkout (where you enter personal information and choose payment method) is shown in the right-hand column.

Sometimes you need to change the design of the checkout page and with Klarna Checkout for WooCommerce it is possible in a couple of different ways.

1. Simple CSS changes

If you only want to make minor design changes, CSS adjustments may be enough to get you where you want.
For example, to create a checkout page with a single-column layout, add the following CSS to your theme:

2. Remove, add and move with action hooks

If you want to make some more extensive changes to the layout of the checkout page, it is recommended to work with action hooks.
The checkout template file
On the Klarna Checkout template page, there are several action hooks you can use to add code or content. These hooks have the following names:
  • woocommerce_before_checkout_form
  • kco_wc_before_order_review
  • kco_wc_after_order_review
  • kco_wc_before_snippet
  • kco_wc_after_snippet
  • woocommerce_after_checkout_form
You can find their location here:

Through these action hooks, you can easily add information to different locations on the checkout page.

3. Create your own template file

If you need to make changes that can’t be accomplished via action hooks, then you are able to overwrite the checkout template file via your theme. The plugin supports WooCommerce’s way of handling template files.
The template file used for displaying Klarna Checkout is called klarna-checkout.php and it is located in the templates folder in the plugin. To overwrite the file, copy it from the plugin, then paste it into the /woocommerce folder in your theme. Now you have the opportunity to make the changes you want. Keep in mind that the action hooks kco_wc_before_checkout_form and kco_wc_after_snippetmust remain for the plugin to work properly.


Action filters are used to modify data before sending it to an external service, rendering it in the browser or storing it in a database. The most common occasion this might be used in the plugin is if you want to modify the order/cart data sent to Klarna before the KCO checkout is rendered.

1. Modify order data sent to Klarna

To modify the order data sent to Klarna (actually the cart data since the WooCommerce order isn’t created until after the purchase is finalized in Klarna Checkout), you use the filter kco_wc_api_request_args as described in the following example:

Information about available parameters in Klarnas API can be found here.

2. Display Klarna Checkout even on free orders

If you have a coupon that brings the total order value down to zero making the order free for the customer, by default this will show the standard WooCommerce checkout instead of the Klarna Checkout. If you would rather want to show the Klarna Checkout for this you can use the filter kco_check_if_needs_payment. And return false instead of true to this filter.

3. Set a forced purchase country

If you need to set a forced purchase country for any reason other then what the store country is and you don't want to use geolocation, then you can use this snippet to do so. Simply change SE for any other two letter country code that you want to use.

4. Only accept purchases from customer over 18 years of age.

Code example on how to only accept purchases from people over 18 years of age with Klarna Checkout for WooCommerce (plugin for Klarnas v3 platform - https://wordpress.org/plugins/klarna-checkout-for-woocommerce/).

This only works if Klarna has activated the "Allow merchant to read customers national identification number" setting in your account…
Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.