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
- Pending payment orders and held stock
Extra checkout fields
With Klarna Checkout you have an embedded checkout solution that handles both payment methods and customer address fields. In some cases you might need to collect more information than the regular customer address data.
Default checkout fields
The Klarna Checkout for WooCommerce plugin retrieve and populate following address data in WC()->customer
right before the checkout form is submitted and the order is created in WooCommerce:
- Billing First name
- Billing Last name
- Billing Postcode
- Billing City
- Billing State (if needed)
- Billing Country
- Phone
- Email address
- Shipping First name
- Shipping Last name
- Shipping Postcode
- Shipping City
- Shipping State (if needed)
- Shipping Country
Custom checkout fields
The plugin also handles extra checkout fields that has been added via the filter woocommerce_checkout_fields
. These fields will then be displayed below the order notes textarea field.
An example
If you add the following code as a plugin or in your themes functions.php file:
/**
* More information about custom checkout fields: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters
*
* Add the custom field to the checkout
*/
add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
function my_custom_checkout_field( $checkout ) {
woocommerce_form_field(
'my_field_name',
array(
'type' => 'text',
'class' => array( 'my-field-class form-row-wide' ),
'label' => __( 'Custom info' ),
'placeholder' => __( 'Enter something' ),
'required' => true,
),
$checkout->get_value( 'my_field_name' )
);
}
/**
* Update the order meta with field value
*/
add_action( 'woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta' );
function my_custom_checkout_field_update_order_meta( $order_id ) {
if ( ! empty( $_POST['my_field_name'] ) ) {
update_post_meta( $order_id, 'My Field', sanitize_text_field( $_POST['my_field_name'] ) );
}
}
Then the field will be displayed like this:
In this case we made the field a required field. By doing that the purchase will not be finalized when pressing the Place order button until data has been entered into the Custom info field.
Limitations
Custom checkout fields that have been added to the regular WooCommerce checkout form via any of the hooks available inside the form will not be handled/processed by the Klarna Checkout plugin.
Compatibility with checkout field plugins
If you don’t want to add extra checkout fields via custom code there are several plugins that solves this. Klarna Checkout for WooCommerce has been tested with the following checkout field plugins: