Woocommerce: Modifying form fields

Woocommerce provides some filters that we can use to change remove or make certain fields in whatever forms not compulsory.

Say we want to make the billing phone not compulsory and remove the address_2 field in the my-account billing section,

function filter_billing_fields($fields) {
  $fields['billing_phone']['required'] = 0;
  unset($fields['billing_address_2']);
  return $fields;
}
add_filter('woocommerce_billing_fields', 'filter_billing_fields');

Author: bpeh

Bernard Peh is a great passioner of web technologies and one of the co-founder of Sitecritic.net Website Design and Reviews. He works with experienced web designers and developers everyday, developing and designing commercial websites. He specialises mainly in SEO and PHP programming.