billing_state field required for Greece override
-
Hello all,
after many hours trying to override this field via functions.php on the template i found that For Greece on the file: woocommerce\includes\class-wc-countries.php
the field state is not required:‘GR’ => array(
‘state’ => array(
‘required’ => false,
),
),If i set this field to required => true and upload it the system works as expected so there is no issue with any plugin or template.
I would like to solve this without a core hack of course and my two functions do not work do you have something to suggest perhaps?
add_filter( ‘woocommerce_checkout_fields’, ‘custom_override_default_address_fields’ );
function custom_override_default_address_fields($fields){
global $woocommerce;
$country = $woocommerce->customer->get_country();
if($country == ‘GR’){
$fields[‘billing’][‘state’][‘required’] = true;
$fields[‘shipping’][‘state’][‘required’] = true;
}
return $fields;
}add_filter( ‘woocommerce_billing_fields’, ‘formulare_filter_billing_state’, 10, 999 );
function formulare_filter_billing_state( $address_fields ) {
$address_fields[‘billing_state’][‘required’] = true;
return $address_fields;
}
- The topic ‘billing_state field required for Greece override’ is closed to new replies.