Make Billing and Shipping Fields Optional and required in WooCommerce
For not required
- country
- first_name
- last_name
- company
- address_1
- address_2
- city
- state
- 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;
}
Comments
Post a Comment