I added custom states for shipping states.
In checkout page it state shows as optional. I tried to make it required by using follow code in the functions.php file in my child theme.
add_filter( 'woocommerce_billing_fields', 'mp_filter_state_billing');
add_filter( 'woocommerce_shipping_fields', 'mp_filter_state_shipping');
function mp_filter_state_billing( $address_fields ) {
$address_fields['billing_state']['required'] = true;
$address_fields['billing_state']['label'] = 'District';
return $address_fields;
}
function mp_filter_state_shipping( $address_fields ) {
$address_fields['shipping_state']['required'] = true;
$address_fields['shipping_state']['label'] = 'District';
return $address_fields;
}
But it show the correct label for a second and reset back to “State / County (optional)”
How can I fix this