woocommerce_checkout_fields
This filter lets developers adjust the field definitions in WooCommerce's classic shortcode checkout, including billing, shipping, and order-note fields.
Quick Reference
| Type | Filter hook |
|---|---|
| Area | Classic checkout |
| Arguments | $fields (array) |
| Source | WooCommerce code reference |
How It Works
WooCommerce passes a nested checkout-fields array through apply_filters(). Sections commonly include billing, shipping, and order. The order_comments key identifies the order-notes field, while placeholder is one of its settings.
PHP Example
add_filter( 'woocommerce_checkout_fields', function ( $fields ) {
if ( isset( $fields['order']['order_comments'] ) ) {
$fields['order']['order_comments']['placeholder'] = 'Delivery notes (optional)';
}
return $fields;
} );
This changes the order-notes placeholder without assuming the field always exists. The keys are PHP array identifiers, not user-visible labels.
Add the code to a site-specific plugin or a child theme's functions.php file, then test it on a staging site.
Common Pitfalls
Checkout fields use nested PHP array keys. In $fields['order']['order_comments'], order selects the field group and order_comments identifies the order-notes field. The placeholder setting changes its hint text, while label controls its visible label. Keep the internal field key unchanged when you only want to rewrite the wording.
Removing billing or shipping fields can affect address validation, tax calculations, shipping methods, and payment integrations. For a text-only adjustment like this example, change the specific setting and return the rest of the field array intact.
Compatibility
This example targets the classic shortcode checkout. The Checkout block does not support all classic field customizations. For registering new fields in the Checkout block, see WooCommerce's Additional Checkout Fields API.