Created
January 18, 2022 13:20
-
-
Save cubehrends/fef9c4b0f87f9c6f3f4c2e8be7f8f427 to your computer and use it in GitHub Desktop.
check address for required house number on WooCommerce checkout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function wdt_address_field_validation() { | |
$post_value = $_POST['billing_address_1']; | |
if ( $post_value && ! preg_match( '/[0-9]+/', $post_value ) ) { | |
throw new Exception( sprintf( __( 'Das Feld <strong>Straße</strong> muss eine <strong>Hausnummer</strong> beinhalten.', 'woocommerce' ) ) ); | |
} | |
} | |
add_action('woocommerce_checkout_process', 'wdt_address_field_validation', 10, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment