Klarna On-site Messaging

Klarna On-site Messaging

This documentation is for On-site Messaging for Klarna Payments.

As of version 3.5.0 of Klarna Payments for WooCommerce On-site Messaging is now a part of the Klarna Payments plugin.

If you are looking for documentation for On-site Messaging for Klarna Checkout for WooCommerce, please see this link.


Klarna Merchant Portal


To configure On-site Messaging you first need to log in to your Klarna Merchant Portal to retrieve some information needed later.

  1. Log in to your Klarna Merchant Portal.
  2. Navigate to Conversion boosters On-site Messaging.
  3. Select your store and click Get started.
  4. Move on to Configuration

Configuration


Go to → WooCommerce → Settings → Payments → Klarna Payments. At the bottom of the Settings page there is a section called Klarna On-Site Messaging.

  1. Test mode – Check this box to enable Test mode.
  2. Client ID – Enter the Client ID retrieved under the Conversion booster tab in your merchant portal. Copy the value entered inside the data-client-id (just the string inside the double quotes) and paste it in the settings field.
    Please note that Client ID retrieved while the store being in Test mode will not work in Production mode, and vice versa.
  1. Enable/Disable the Product placement – Check this box to display On-Site Messaging on product pages.
  2. Product page placement data key – Enter the product page placement data-key retrieved from your merchant portal.
    In this example we use the credit-promotion-badge
  1. Product On-Site Messaging placement – Set where on the product pages the Klarna On-Site Message should be displayed.
  2. Product Placement Theme – Choose between Default, dark and custom.
  3. Enable/Disable the Cart placement – Check this box to display On-Site Messaging on the cart page.
  4. Cart page placement data key – Enter the cart page placement data-key retrieved from your merchant portal, like in step 4.
  5. Cart On-Site Messaging placement – Set where on the cart page the Klarna On-Site Message should be displayed.
  6. Cart Placement Theme – Choose between Default, dark and custom.
  7. Enable custom placement hook – Check this box to enable custom placement hook.
  8. Custom placement hook – Enter a custom hook where you want the OSM widget to be placed. As an example we use woocommerce_single_product_summary.
    You can find a list of all WooCommerce action and filter hooks and where they operate here.
  9. Custom placement hook priority – Set the priority for the custom hook where you want the OSM widget to be placed.

Now when you navigate to either a product page or the cart page you should see the widget that you setup in your merchant portal.


Display On-site messaging via shortcode


If you wish, you can also display On-site messaging via the shortcode [onsite_messaging].

You can also configure the placement with the following shortcode attributes:

  • data-key (optional)
    The type of placement button/image you want to display. Defaults to homepage-promotion-wide. Look into your Klarna merchant account for possible data-key’s.
  • data-theme (optional)
    The theme/style used to display the button/image. Look into your Klarna merchant account for possible data-theme’s.
  • data-purchase-amount (optional)
    The specific amount used for the placement. Should be entered in cents/minor units (e.g 100 EUR = 10000).

If you use the data-purchase-amount shortcode on a product or cart page but have no amount specified it will automatically be populated based on the product price or order total.

An example shortcode could look like this:

[onsite_messaging data-key="credit-promotion-small" data-purchase-amount="89900" data-theme="dark"]


Display On-Site Messaging via widgets


You also have the possibility to configure and add a placement via WordPress Widgets.

  1. Navigate to Appearance > Widgets.
  2. Click Add block where you want to display the Klarna On-Site Messaging widget.
  1. Start typing Klarna On-site Messaging and click the widget when it appears.
  1. In the configuration of the widget you can add a TitlePlacement Key and select the Placement Theme you would like to use.
  1. If you want to move the widget after you have configured it, you can click and hold Drag to move it to another Widget area.

Conditionally change the data client ID


/*
* The $client_id is the data client ID that you've entered in the OSM settings. You can overwrite it with the this hook.
*
* This function _must_ return a client id or OSM will fail to work. You may default to returning $client_id as in the example below.
*/
add_filter('kosm_data_client_id', function( $client_id ) {
	
	// your logic here...
	
	return $client_id;
});

Customize region dependent JS libraries


/* 
 * This filter let you change which regional library to use, and is necessary if you want to display KOSM to customers from different regions.
 * 
 * The library region must match the customer's region for KOSM to be displayed.
 * 
 * Valid return values:
 * - 'na-library' for US, CA.
 * - 'oc-library' for AU, NZ.
 * - 'eu-library' for EU (default).
 */
add_filter('kosm_region_library', function( $region ) {
	return 'eu-library';
});

Force locale to a specific country


Klarna On-site Messaging listens to https://developer.wordpress.org/reference/functions/get_locale/ to set the locale. With this snippet you can force a specific country, Spain in the example below.

add_filter('kosm_default_euro_locale', function($locale) {
    return 'es-ES';
});

FAQ


I have activated OSM (On-Site Messaging) for my store but it is not displayed to all customers

If the customer currency is not supported by Klarna, OSM will not be displayed.


I want to use a Custom Design that I made in the Klarna Merchant Portal but I can’t see the changes I make

To be able to see the Custom Design changes you need to set the setting Product Placement Theme to None and Cart Placement Theme to None.


OSM worked in test mode but not when the store is live

If you have had On-Site Messaging activated while testing your Klarna Payments plugin you need to make sure that you enter the production Data client ID for OSM once you have unchecked Test mode and your store is live.

If you use the Data client ID retrieved while the store was in Test mode OSM will not work in production, and vice versa.


Why is the “credit-promotion-badge” not visible on products with a price over 100 Euro?

I have activated the placement “credit-promotion-badge” in OSM on my product page and I see it on products BELOW 100 Euro, but not on products OVER 100 Euro?

This might be because there is a upper limit for financing in your agreement with Klarna, this is probably why the credit-promotion-badge won’t show over a certain amount. Get in touch with the commercial team at Klarna if you want to change the limit in your agreement.