Skip to content

Instantly share code, notes, and snippets.

  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vyskoczilova/dbd8cb4d2ca12e40b8ec12af2f0b043a to your computer and use it in GitHub Desktop.
WooCommerce: Ulice (první řádek) obsahuje alespoň jednu číslici (číslo popisné)
<?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