WooCommerce changed. The classic answer still adds the field. The Checkout block never shows it.
The case
The client’s accountant: “Why is there no VAT number in the orders for the last two weeks?”
The field was added with woocommerce_checkout_fields. Two weeks ago the checkout page was rebuilt on the Checkout block. The field just disappeared: no error, no warning in the log.
The hook didn’t break. Nobody calls it.
Why
| Classic checkout | Block checkout | |
|---|---|---|
| Form | PHP, | React block |
| Request | ?wc-ajax=checkout | Store API /wc/store/v1/checkout |
| Form hooks | woocommerce_checkout_fields, woocommerce_checkout_process | not called |
| Order hooks | woocommerce_order_status_*, woocommerce_payment_complete | work in both |
The fix
<?php
add_action( 'woocommerce_init', static function () {
if ( ! function_exists( 'woocommerce_register_additional_checkout_field' ) ) {
return;
}
woocommerce_register_additional_checkout_field( [
'id' => 'forwp/vat-number',
'label' => __( 'VAT number', 'forwp' ),
'location' => 'order',
'type' => 'text',
'required' => false,
] );
} );
The interview question
The client moved to block checkout and the VAT field disappeared. What do you do?
Weak answer. Add the field again through
woocommerce_checkout_fields.
Strong answer. Block checkout doesn’t read
woocommerce_checkout_fields, it works through the Store API. I register the field with the Additional Checkout Fields API with validation. I check where other parts read the field: emails, admin, export. The value is now stored under a different meta key, so I update those places. For old orders I keep reading the old key.
👉 The full chapter is in the course WooCommerce Development for Middle Devs: Module 4. Cart and Checkout
🔔 More WooCommerce videos: youtube.com/@4wpdev