Created
July 30, 2021 13:08
Star
You must be signed in to star a gist
WooCommerce: Ulice (první řádek) obsahuje alespoň jednu číslici (číslo popisné)
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 // nekopírujte tento řádek | |
/** | |
* @snippet WooCommerce: Ulice (první řádek) obsahuje alespoň jednu číslici (číslo popisné) | |
* @author Karolína Vyskočilová (https://kybernaut.cz) | |
* @testedwith WordPress 5.8 & WooCommmerce 5.5 | |
*/ | |
function my_theme_validate_street( $fields, $errors ){ | |
if ( ! preg_match('/[0-9]+/', $fields['billing_address_1']) && !empty( $fields['billing_address_1'] ) ) { | |
$errors->add( 'validation', __( '<strong>Adresa ulice</strong> musí obsahovat číslo popisné.', 'my-theme' ) ); | |
} | |
} | |
add_action( 'woocommerce_after_checkout_validation', 'my_theme_validate_street', 10, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment