How to remove input fields from Checkout page in Woo-Commerce?
There are simple steps to remove any field from checkout form. A PHP function unset( ); is used to remove fields in checkout page. To do so, open functions file of current theme. Add a new function to unset the fields to unset. $field variabe needs to be passed to function. For example, if Company name needs to hide from checkout page them billing_company field is used. At last fields needs to return.
function custom_override_checkout_fields( $fields ) { unset($fields['billing']['billing_company']); unset($fields['billing']['billing_address_1']); unset($fields['billing']['billing_address_2']); unset($fields['billing']['billing_city']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_state']); return $fields; }
At last add_filter( ) function of woo-commerce is used to unset all fields as follow.
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
That’s it.