Skip to content

Instantly share code, notes, and snippets.

@NiklasHogefjord
Last active May 11, 2018 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NiklasHogefjord/762ddccf64e52d795fb83fe4adff5321 to your computer and use it in GitHub Desktop.
Save NiklasHogefjord/762ddccf64e52d795fb83fe4adff5321 to your computer and use it in GitHub Desktop.
Display a checkbox in KCO that is required to check to be able to complete purchase. This is used for the WooCommerce Klarna gateway (v2).
<?php
// Add a cehckbox to KCO iframe that is required to check before the purchase can be completed
add_filter('kco_create_order', 'krokedil_add_required_checkbox');
add_filter('kco_update_order', '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