Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Display a checkbox in KCO that is required to check before the purchase can be completed. This can be used both for the WooCommerce Klarna gateway (v2) and Klarna Checkout for WooCommerce (v3) plugin.
<?php
/**
* WooCommerce - Klarna payment gateway & Klarna Checkout for WooCommerce
* Add a cehckbox to KCO iframe that is required to check before the purchase can be completed
**/
// V2 - old Klarna plugin
add_filter('kco_create_order', 'krokedil_add_required_checkbox');
add_filter('kco_update_order', 'krokedil_add_required_checkbox');
// V3 - new Klarna checkout plugin
add_filter('kco_wc_api_request_args', 'krokedil_add_required_checkbox');
function krokedil_add_required_checkbox( $create ) {
$create['options']['additional_checkbox']['text'] = 'I agree to the <a href="https://example.com/terms" target="_blank">terms</a> and data policy.';
$create['options']['additional_checkbox']['checked'] = false;
$create['options']['additional_checkbox']['required'] = true;
return $create;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.