Your woocommerce_checkout_fields filter is not broken. It is simply never called. The WooCommerce Checkout block is a React front end that talks to the Store API, and a Store API request never loads the classic checkout template, so none of the PHP hooks that template used to fire get a chance to run. The supported replacement is the Additional Checkout Fields API: you register a field once in PHP, on the server, and WooCommerce renders it inside the block, carries it through the Store API, and saves it on the order. This guide walks that path end to end, shows you exactly where the value lands so you can read it back with confidence, and is honest about the customisations the block still will not do.
What you’ll accomplish
- Confirm from the command line whether your store is actually running the Checkout block, and whether your WooCommerce release has the field API at all.
- Register a custom checkout field from a small site plugin, in the correct location, so it renders in the block without touching a template.
- Find the exact meta key the value is stored under on the order, instead of guessing it from a blog post.
- Surface the value where your fulfilment people actually look: the admin order screen and the order emails.
- Know the point at which the block cannot do what you need, and how to fall back to the shortcode checkout in one command.
Prerequisites
A current WooCommerce release on WordPress 6.5 or newer, PHP 8.1 or later, and shell access with WP-CLI available as wp, run as the site user from the WordPress root. The Additional Checkout Fields API arrived partway through the WooCommerce 8.x line and has gained field types and options in every release since, so the version you are on decides which options are available to you. Do not take a version number from memory. The first command in the step-by-step section tests for the API directly, which is the only answer that matters.
Two assumptions. First, that you have already decided the block is where you want to be. If you are still weighing it, read Checkout block vs shortcode first, because the inventory work there is what tells you whether this article is a two-hour job or a two-week one. Second, that you do this on a staging copy of the store, place a real test order through it, and only then move the plugin to production. A checkout field that fails validation in a way the customer cannot clear is an outage with a revenue number attached to it.
How it works
The classic checkout and the block checkout are two different programs that happen to sell the same products.
On the shortcode side, WordPress loads a page, WooCommerce loads form-checkout.php, and every field on the screen is the product of PHP filters running during that render. woocommerce_checkout_fields reshapes the array, woocommerce_form_field prints each input, and a plain form POST back to the same page hands your data to woocommerce_checkout_update_order_meta. Everything happens inside one PHP request, which is why a snippet in functions.php could bend it.
On the block side, WordPress serves a page containing a block that boots a JavaScript application. That application asks the Store API what the checkout looks like, renders inputs from the schema it gets back, and finally POSTs the whole checkout to a REST route. Your PHP still runs, but it runs during a REST request, not during a template render. Filters that expected a template are never reached.
So the API is a registry rather than a filter. You tell WooCommerce, once and unconditionally, that a field exists and what shape it has. WooCommerce puts it in the schema, the block renders it, the Store API validates and accepts it, and the order gets the value. The one rule that catches people is that registration must happen on every request, including REST requests. Registering inside is_checkout() or on a hook that only fires on front-end page loads produces a field that appears in the browser and then vanishes when the order is submitted.
Where the field appears is a property of the field, not of a template hook. There are three locations, and picking the right one is most of the design work.
A contact field sits with the email address at the top of the checkout and is the right home for something about the person: a tax registration number, a marketing preference. An address field is rendered inside the address forms, which means billing and shipping each get their own copy of it and each carries its own value. An order field renders down near the order notes and belongs to that order alone, which is what you want for a delivery window or a purchase order reference that should not follow the customer to their next order.
Step-by-step
- Prove your checkout page is actually the block. Plenty of stores think they migrated and did not, or migrated and a plugin quietly put the shortcode back.
wp post get "$(wp option get woocommerce_checkout_page_id)" --field=post_content | head -c 120
Expected output opens with a block comment naming the checkout block: <!-- wp:woocommerce/checkout followed either by a self-closing marker or by inner blocks, depending on how the page was created. If instead you see [woocommerce_checkout], stop here and keep using your existing PHP filters, because they still work. If you see wp:woocommerce/classic-shortcode, you are on a block theme still rendering the classic form, and the same applies.
- Prove your WooCommerce release has the API. This is worth more than any version table.
wp eval 'echo function_exists( "woocommerce_register_additional_checkout_field" ) ? "available" : "missing", PHP_EOL;'
Expected output is available. If it prints missing, your WooCommerce is older than the field API and no amount of code will change that. Update WooCommerce on staging first.
- Create a site plugin to hold the registration. Put this in a plugin, not in the theme. A theme can be switched, and some environments load theme code differently on REST requests. A plugin is the only place that is loaded identically on every request.
mkdir -p wp-content/plugins/shop-checkout-fields
cat > wp-content/plugins/shop-checkout-fields/shop-checkout-fields.php <<'PHP'
<?php
/**
* Plugin Name: Shop Checkout Fields
* Description: Registers additional checkout fields for the WooCommerce Checkout block.
* Version: 1.0.0
* Requires Plugins: woocommerce
*/
defined( 'ABSPATH' ) || exit;
add_action(
'woocommerce_init',
function () {
if ( ! function_exists( 'woocommerce_register_additional_checkout_field' ) ) {
return;
}
woocommerce_register_additional_checkout_field(
array(
'id' => 'shop/delivery-note',
'label' => 'Delivery note for the driver',
'location' => 'order',
'type' => 'text',
'required' => false,
'attributes' => array(
'autocomplete' => 'off',
'aria-label' => 'Delivery note for the driver',
),
)
);
}
);
PHP
There is no output on success. Three details in that array carry all the weight. The id must be namespaced with a prefix you own, in the namespace/field-name shape, because the namespace is what keeps your field from colliding with a plugin’s. The location is one of the three from the diagram above. And the whole thing is hooked on woocommerce_init with no conditional wrapper, which is what makes it exist during the REST request too.
- Check the file parses, then activate it.
php -l wp-content/plugins/shop-checkout-fields/shop-checkout-fields.php
wp plugin activate shop-checkout-fields
Expected output is No syntax errors detected followed by Success: Activated 1 of 1 plugins. If activation triggers a fatal error, WP-CLI prints the PHP error rather than the success line, and the message names the file and line.
-
Load the checkout in a browser and place a test order. Add a product, go to the checkout page, and confirm the field renders where the location said it would. Fill it with a value you will recognise later, something like
TEST-VALUE-1, and complete the order with a test gateway such as cash on delivery. -
Find the meta key the value was stored under. This is the step to do rather than assume. The storage key is derived from the location group and your namespaced id, and the shape of that prefix has changed across releases, so read it off a real order instead of hardcoding what a tutorial told you.
wp eval '$ids = wc_get_orders( array( "limit" => 1, "return" => "ids", "orderby" => "date", "order" => "DESC" ) ); $o = wc_get_order( $ids[0] ); echo "order " . $o->get_id() . PHP_EOL; foreach ( $o->get_meta_data() as $m ) { $d = $m->get_data(); echo $d["key"] . " = " . ( is_scalar( $d["value"] ) ? $d["value"] : wp_json_encode( $d["value"] ) ) . PHP_EOL; }'
Expected output is the order number followed by every meta key on that order, one per line. Find the line whose value is TEST-VALUE-1 and copy the key on the left verbatim. That string is the contract between the checkout and every piece of code you write next.
- Read the value back in your own code. With the key in hand, reading it is ordinary WooCommerce. This works the same whether the store uses the legacy post tables or High-Performance Order Storage, which is exactly why you go through the order object rather than
get_post_meta.
$order = wc_get_order( $order_id );
$note = $order->get_meta( 'PASTE_THE_KEY_YOU_FOUND' );
- Put it in the order emails. WooCommerce shows registered fields on the customer-facing order confirmation and on the admin order screen without you doing anything. Emails are the piece worth checking by hand, and the classic filter still works there because emails are rendered in PHP.
add_filter(
'woocommerce_email_order_meta_fields',
function ( $fields, $sent_to_admin, $order ) {
$key = 'PASTE_THE_KEY_YOU_FOUND';
$value = $order->get_meta( $key );
if ( $value ) {
$fields['shop_delivery_note'] = array(
'label' => __( 'Delivery note', 'shop-checkout-fields' ),
'value' => $value,
);
}
return $fields;
},
10,
3
);
Success signal: place another test order and the line appears under the order table in the email. If the field is already there twice, WooCommerce is rendering it for you and you can drop this filter.
Validate it works
Run the two checks that fail loudest first, then the end-to-end one.
wp eval 'echo function_exists( "woocommerce_register_additional_checkout_field" ) ? "api ok" : "api missing", PHP_EOL;'
wp plugin list --status=active --field=name | grep shop-checkout-fields
Expected output is api ok and shop-checkout-fields. Then place a fresh test order with a distinctive value and confirm it survived the round trip:
wp eval '$ids = wc_get_orders( array( "limit" => 1, "return" => "ids", "orderby" => "date", "order" => "DESC" ) ); $o = wc_get_order( $ids[0] ); echo $o->get_meta( "PASTE_THE_KEY_YOU_FOUND" ), PHP_EOL;'
Expected output is the exact string you typed at the checkout. If it prints an empty line while the field was clearly visible on the checkout page, the field rendered but the registration was not present during the REST request, which is almost always the conditional-wrapper mistake from step 3. Finish by opening the order in the admin, where the value should appear alongside the billing details, and by opening the order confirmation page as the customer.
Troubleshooting
The field never appears in the block. Deactivate and reactivate the plugin, then reload the checkout with a hard refresh, because the block caches the schema it fetched. If it is still absent, the registration is not running: check that the plugin is active, that woocommerce_init is the hook you used, and that nothing above the registration returns early.
The field appears but the value is empty on the order. The registration exists on page loads but not on REST requests. Move it out of the theme, out of any is_checkout() or is_admin() guard, and out of any hook that fires later than woocommerce_init.
Activation triggers a fatal error mentioning a duplicate or invalid id. Two plugins registered the same id, or your id has no namespace prefix. Turn on the debug log and read the real message rather than guessing.
wp config set WP_DEBUG true --raw
wp config set WP_DEBUG_LOG true --raw
tail -n 40 wp-content/debug.log
Turn both back off on production when you are done.
A required field blocks checkout and the customer cannot clear it. Set required to false, ship that, and then work out why the validation was unsatisfiable. A required field whose only valid input is not reachable from the UI will hold every order in the store hostage, so the rollback comes first.
An old plugin claims to add checkout fields and does nothing. It is filtering woocommerce_checkout_fields. That code is not failing, it is not running. Either the plugin ships block support in a newer version or it does not, and no snippet on your side bridges the gap.
When this is the wrong approach
The field API registers static fields. It does not give you conditional display, so “only show the delivery window when the cart contains a fridge” or “only ask for a tax number when the shipping country is outside Canada” is not something you express in the registration array. Doing it anyway means writing JavaScript against the block’s internal data stores, which is unversioned surface that can move under you in a minor release. That is a maintenance commitment, not a snippet.
Reordering the checkout, removing core fields, splitting it into steps, or rendering your own markup between the address and the payment section are also outside what the registration API covers. If your requirement is a layout requirement rather than a data requirement, you are looking at block development, not field registration.
And if the honest inventory says you have a dozen classic checkout snippets, a gateway with no block support, and no budget to rewrite them, the right call is the boring one: stay on, or go back to, the shortcode checkout and revisit in six months. Back up the page content, then restore it.
wp post get "$(wp option get woocommerce_checkout_page_id)" --field=post_content > ~/checkout-page-backup.html
wp post update "$(wp option get woocommerce_checkout_page_id)" --post_content='[woocommerce_checkout]'
Expected output is Success: Updated post <id>. Reload the checkout and your classic filters are alive again, exactly as they were.
Before you write any registration array, confirm your version’s option list against the WooCommerce developer documentation, and keep the WP-CLI command reference open for the inspection commands above. If a theme template is also involved, overriding WooCommerce templates in a theme covers the part of the store the block did not take over, and add to cart not working is the article to read if your test orders never reach the checkout in the first place.
Running WordPress that earns real money deserves an operator — Stack Harbor runs that stack under Enterprise WordPress; book an infrastructure consult.