Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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( __('You must enter your house number for the billing address'), 'error' );
- else
- $woocommerce->add_error( __('You must enter your house number for the billing address') );
- }
- }
- 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( __('You must enter your house number for the shipping address'), 'error' );
- else
- $woocommerce->add_error( __('You must enter your house number for the shipping address') );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement