February 07, 2020
This comes in handy if the ecommerce store does not ship any physical materials (e.g., downloadable, e-tickets, online classes, membership, etc).
// remove address fields from billing form
add_filter('woocommerce_billing_fields','wpb_custom_billing_fields');
function wpb_custom_billing_fields( $fields = array() ) {
unset($fields['billing_company']);
unset($fields['billing_address_1']);
unset($fields['billing_address_2']);
unset($fields['billing_state']);
unset($fields['billing_city']);
unset($fields['billing_phone']);
unset($fields['billing_postcode']);
unset($fields['billing_country']);
return $fields;
}
// remove address fields from checkout form
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields_ek', 99 );
function custom_override_checkout_fields_ek( $fields ) {
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_state']);
return $fields;
}
More information available where I found this snippet.