Adding Custom Checkout Fields to WooCommerce Checkout
WooCommerce gives you a powerful checkout experience out of the box, but sooner or later you'll need a field that isn't there by default — a delivery note, a company tax ID, or a custom product option that follows the order through to fulfillment.
The good news: WooCommerce has hooks for exactly this, and you don't need a plugin to make it happen.
The Three Hooks You Need
Adding a custom checkout field in WooCommerce involves three steps:
- Display the field —
woocommerce_after_order_notes(or another position hook) - Validate the field —
woocommerce_checkout_process - Save the field —
woocommerce_checkout_update_order_meta
Displaying the Field
add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' );
function my_custom_checkout_field( $checkout ) {
woocommerce_form_field( 'delivery_note', array(
'type' => 'textarea',
'class' => array( 'form-row-wide' ),
'label' => __( 'Delivery Note', 'woocommerce' ),
'placeholder' => __( 'Any special delivery instructions?', 'woocommerce' ),
'required' => false,
), $checkout->get_value( 'delivery_note' ) );
}
Saving the Field
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['delivery_note'] ) ) {
update_post_meta( $order_id, '_delivery_note', sanitize_textarea_field( $_POST['delivery_note'] ) );
}
}
Displaying It in the Admin Order View
Once saved, you'll want to surface this in the order admin screen:
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 );
function my_custom_checkout_field_display_admin_order_meta( $order ) {
$note = get_post_meta( $order->get_id(), '_delivery_note', true );
if ( $note ) {
echo '<p><strong>' . __( 'Delivery Note' ) . ':</strong> ' . esc_html( $note ) . '</p>';
}
}
Wrapping Up
This pattern covers the majority of custom checkout field use cases. For more complex scenarios — conditional fields, fields tied to specific products, or fields that affect shipping — the same hooks apply, just with extra conditional logic layered in.
This post is a placeholder — full content coming soon.