Make the Company Name Required
Turns the optional Company field into a required one for stores that sell only to businesses.
Opens WPIDE on
Code
add_filter( 'woocommerce_billing_fields', function ( $fields ) {
if ( isset( $fields['billing_company'] ) ) {
$fields['billing_company']['required'] = true;
}
return $fields;
}, 20 );
Notes
Make sure the Company field is not hidden in Appearance > Customize > WooCommerce > Checkout.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.