WooCommerce Checkout Hooks: Customise the Checkout With Examples

Add, remove and validate checkout fields, save custom data to the order, change the Place order button and add content around the checkout, with working WooCommerce hooks and an important note on the block checkout.

The checkout is where small changes make a real difference: one field fewer, a clearer button, a note about delivery times. WooCommerce offers hooks for nearly all of it. This guide walks through the checkout hooks you’ll use most, with examples you can copy. For the full list of every WooCommerce action and filter, see our WooCommerce hooks reference.

Before you start: classic or block checkout?

The hooks in this article work with the classic checkout: a checkout page built from the [woocommerce_checkout] shortcode. Since WooCommerce 8.3, new stores get the Checkout block instead, which ignores most of these PHP hooks and uses its own extension API. Open your checkout page in the editor: if you see a “Checkout” block rather than the shortcode, these examples won’t change it. You can switch the page back to the classic shortcode, or use WooCommerce’s block extensibility (for extra fields, woocommerce_register_additional_checkout_field()).

1. Remove, rename or reorder checkout fields

woocommerce_checkout_fields receives every checkout field grouped into billing, shipping, account and order. Change the array and return it:

functions.php
add_filter( 'woocommerce_checkout_fields', function ( $fields ) {
	// Remove the company field.
	unset( $fields['billing']['billing_company'] );

	// Make the phone optional and give it a clearer label.
	$fields['billing']['billing_phone']['required'] = false;
	$fields['billing']['billing_phone']['label']    = __( 'Phone (for delivery updates)', 'my-site' );

	// Show email first.
	$fields['billing']['billing_email']['priority'] = 5;

	return $fields;
} );

2. Add a custom field

The same filter adds fields. This one asks for a delivery note in the order section:

functions.php
add_filter( 'woocommerce_checkout_fields', function ( $fields ) {
	$fields['order']['delivery_note'] = array(
		'type'     => 'text',
		'label'    => __( 'Gate code or delivery note', 'my-site' ),
		'required' => false,
		'priority' => 20,
	);
	return $fields;
} );

3. Validate a field

woocommerce_after_checkout_validation runs after WooCommerce’s own checks, with the posted data and a WP_Error object. Add an error and the order is not placed:

functions.php
add_action( 'woocommerce_after_checkout_validation', function ( $data, $errors ) {
	if ( ! empty( $data['delivery_note'] ) && strlen( $data['delivery_note'] ) > 100 ) {
		$errors->add( 'delivery_note', __( 'Please keep the delivery note under 100 characters.', 'my-site' ) );
	}
}, 10, 2 );

4. Save the field to the order

Use woocommerce_checkout_create_order, which passes the order object before it is saved. It works with WooCommerce’s newer order storage (HPOS), unlike code that writes post meta directly:

functions.php
add_action( 'woocommerce_checkout_create_order', function ( $order, $data ) {
	if ( ! empty( $data['delivery_note'] ) ) {
		$order->update_meta_data( '_delivery_note', sanitize_text_field( $data['delivery_note'] ) );
	}
}, 10, 2 );

Older tutorials use woocommerce_checkout_update_order_meta with update_post_meta(). That hook still exists, but writing to post meta bypasses HPOS; prefer the order object as above.

5. Show the field in the admin and emails

functions.php
// Order screen, under the billing address.
add_action( 'woocommerce_admin_order_data_after_billing_address', function ( $order ) {
	$note = $order->get_meta( '_delivery_note' );
	if ( $note ) {
		echo '<p><strong>' . esc_html__( 'Delivery note:', 'my-site' ) . '</strong> ' . esc_html( $note ) . '</p>';
	}
} );

// Order emails.
add_filter( 'woocommerce_email_order_meta_fields', function ( $fields, $sent_to_admin, $order ) {
	$note = $order->get_meta( '_delivery_note' );
	if ( $note ) {
		$fields['delivery_note'] = array( 'label' => __( 'Delivery note', 'my-site' ), 'value' => $note );
	}
	return $fields;
}, 10, 3 );

6. Change the “Place order” button

functions.php
add_filter( 'woocommerce_order_button_text', function () {
	return __( 'Pay securely', 'my-site' );
} );

7. Add content around the checkout

Template actions let you print content at fixed points. woocommerce_before_checkout_form runs above the form, and woocommerce_review_order_before_submit just above the button:

functions.php
add_action( 'woocommerce_review_order_before_submit', function () {
	echo '<p class="checkout-note">' . esc_html__( 'Orders placed before 2 pm ship the same day.', 'my-site' ) . '</p>';
} );

8. Turn off order notes

functions.php
add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );

9. Run code after an order is placed

woocommerce_checkout_order_processed fires once the order exists, with the order ID, the posted data and the order. For anything that should happen only after payment, use the order status hooks (for example woocommerce_order_status_processing) instead, since the customer may still abandon payment.

functions.php
add_action( 'woocommerce_checkout_order_processed', function ( $order_id, $posted_data, $order ) {
	$order->add_order_note( __( 'Order placed through the classic checkout.', 'my-site' ) );
}, 10, 3 );

Testing checklist

  • Test on a staging copy with a test payment method, never on the live shop first.
  • Place a guest order and a logged-in order.
  • Check the order screen and the customer and admin emails for your custom data.
  • After WooCommerce updates, check the “Changes by version” section of the WooCommerce hooks reference.

Want a checkout change built for you, classic or block? Send us the details.

Leave a Reply

Your email address will not be published. Required fields are marked *