I have added extra registration fields to the WooCommerce registration form. Among these fields are fields for state and country.
The validation for the state field is done using the following snippet:
if (isset($_POST['billing_state']) && empty($_POST['billing_state']) ) {
$validation_errors->add('billing_state_error', __('Please enter your State', 'woocommerce'));
}
The validation works fine but I noticed that when a country like Netherlands is chosen, the state field disappears since Netherlands does not have any states. This is ok but when I click on the Sign Up button, the validation for state still runs even though the field is no longer there.
Would anyone know what change I will need to make in order to skip the validation for a field if it is hidden? Thank you.
from WooCommerce User Registration - Disable state validation for countries with no state
No comments:
Post a Comment