How to Make Billing and Shipping Fields Optional and required in WooCommerce

Make Billing and Shipping Fields Optional and required in WooCommerce




For not required
  1. country
  2. first_name
  3. last_name
  4. company
  5. address_1
  6. address_2
  7. city
  8. state
  9. postcode

add_filter( ‘woocommerce_default_address_fields’ , ‘optional_default_address_fields’ );
function optional_default_address_fields( $address_fields ) {
$address_fields[‘company’][‘required’] = false;
$address_fields[‘postcode’][‘required’] = false;
$address_fields[‘city’][‘required’] = false;
$address_fields[‘state’][‘required’] = false;
return $address_fields;
}
For required


add_filter( ‘woocommerce_default_address_fields’ , ‘optional_default_address_fields’ );
function optional_default_address_fields( $address_fields ) {
$address_fields[‘company’][‘required’] = true;
$address_fields[‘postcode’][‘required’] = true;
$address_fields[‘city’][‘required’] = true;
$address_fields[‘state’][‘required’] = true;
return $address_fields;
}

The post How to Make Billing and Shipping Fields Optional and required in WooCommerce appeared first on wpcodekit.

Leave a Reply

Your email address will not be published. Required fields are marked *