Skip to content

Instantly share code, notes, and snippets.

@digitalchild
Created April 25, 2017 03:37
Show Gist options
  • Save digitalchild/074ccd8f9c9c017bd2e8d7ca0910fdfd to your computer and use it in GitHub Desktop.
Save digitalchild/074ccd8f9c9c017bd2e8d7ca0910fdfd to your computer and use it in GitHub Desktop.
check address
<?php
add_action( 'woocommerce_checkout_process', 'address_has_number');
function address_has_number() {
$billing_address_1 = $_POST[ 'billing_address_1' ];
if ( preg_match('/^\d/', $billing_address_1 ) === 1 ){
wc_add_notice( __( 'Your address does not have a number.' ), 'error' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment