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');
Like it.? Share it:

Comments are closed.