Get started
Customization
Troubleshooting
- Embedded checkouts in WooCommerce
- Checkout blocks in WooCommerce
- Error codes
- Compatible plugins
- Known compatibility issues
- Shipping Methods in iframe
- FAQ
- Optimizing your checkout when using an Iframe-based checkout
- Callbacks
- Troubleshooting the checkout flow
- Troubleshooting the Pay for order/Hosted Payment Page flow
- Troubleshooting WooCommerce Subscriptions and KCO
- Klarna Developer logs
- Pending payment orders and held stock
Klarna support information
Additional Klarna plugins
Extra merchant data (EMD)
Filter order data sent to Klarna for adding EMD (Extra Merchant Data). Add-on functionality for Klarna Checkout for WooCommerce.
This code is not needed for WooCommerce Subscriptions since the function for subscription data is already implemented in Klarna Checkout.
<?php
/**
* Filter order data sent to Klarna for adding EMD (Extra Merchant Data).
*
* Add-on functionality to Klarna Checkout for WooCommerce (https://wordpress.org/plugins/klarna-checkout-for-woocommerce/).
* This should be used for Klarnas new platform V3.
*
* Learn more about available attachment types here: https://docs.klarna.com/klarna-checkout/popular-use-cases/extra-merchant-data/#how-its-done
**/
add_filter('kco_wc_api_request_args', 'emd_kco_wc_api_request_args');
function emd_kco_wc_api_request_args( $request_args ) {
if( is_user_logged_in() ) {
// User is logged in - add user_login as unique_account_identifier
$current_user = wp_get_current_user();
$klarna_emd_info = array(
'unique_account_identifier' => $current_user->user_login,
'account_registration_date' => date( 'Y-m-d\TH:i', strtotime( $current_user->user_registered ) ),
'account_last_modified' => date( 'Y-m-d\TH:i' ),
);
$klarna_emd_info = array( $klarna_emd_info );
} else {
// User is not logged in - send empty params
$klarna_emd_info = array(
'unique_account_identifier' => '',
);
$klarna_emd_info = array( $klarna_emd_info );
}
$body_attachment = json_encode( array(
'customer_account_info' => $klarna_emd_info
) );
$request_args['attachment']['content_type'] = 'application/vnd.klarna.internal.emd-v2+json';
$request_args['attachment']['body'] = $body_attachment;
return $request_args;
}
Adding the code
There are several ways to add code to your site, a couple of examples are:
- Code snippets
- Modify the theme’s
functions.php
file or include it in a separate functionality plugin.
Please note that we at Krokedil do not offer support for third party plugins.