Skip to content

Instantly share code, notes, and snippets.

@daveloodts
Created January 19, 2021 08:24
Show Gist options
  • Save daveloodts/1a78a9575f7b8151c06512b4d1cb9ca3 to your computer and use it in GitHub Desktop.
Save daveloodts/1a78a9575f7b8151c06512b4d1cb9ca3 to your computer and use it in GitHub Desktop.
// Check if address field contains house number otherwise provide error message
add_action( 'woocommerce_after_checkout_validation', 'validate_checkout', 10, 2);
function validate_checkout( $data, $errors ){
if ( ! preg_match('/[0-9]/', $data[ 'billing_address_1' ] ) ){
$errors->add( 'address', 'Het adresveld bevat geen huisnummer of busnummer.' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment