Last active
February 24, 2022 12:34
-
-
Save fschmittlein/d00f1ccf7c1e491f05b4b82d8f970abf to your computer and use it in GitHub Desktop.
Ist eine Hausnummer vorhanden?
This file contains hidden or 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
add_action('woocommerce_checkout_process', 'custom_validation_process'); | |
function custom_validation_process() { | |
global $woocommerce; | |
if (isset($_POST['billing_address_1']) and $_POST['billing_address_1'] != '') { | |
if (!preg_match('/([0-9]+)/Uis', $_POST['billing_address_1'])) { | |
if (function_exists('wc_add_notice')) | |
wc_add_notice( __('Hausnummer fehlt!'), 'error' ); | |
else | |
$woocommerce->add_error( __('Hausnummer fehlt!') ); | |
} | |
} | |
if (isset($_POST['ship_to_different_address'])) { | |
if (isset($_POST['shipping_address_1']) and $_POST['shipping_address_1'] != '') { | |
if (!preg_match('/([0-9]+)/Uis', $_POST['shipping_address_1'])) { | |
if (function_exists('wc_add_notice')) | |
wc_add_notice( __('Hausnummer fehlt!'), 'error' ); | |
else | |
$woocommerce->add_error( __('Hausnummer fehlt!') ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment