Last active
March 2, 2023 17:43
-
-
Save clifgriffin/56fbcc449603cfe44dd1af104ad8efc5 to your computer and use it in GitHub Desktop.
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 | |
// Add to functions.php or using the Code Snippets plugin | |
// Do NOT include opening PHP tag above (<?php) | |
add_filter( | |
'woocommerce_default_address_fields', | |
function( $fields ) { | |
unset( $fields['postcode']['custom_attributes']['data-parsley-length'] ); | |
$fields['address_1']['custom_attributes']['data-parsley-pattern'] = '/^(?![A-Za-z][A-Ha-hJ-Yj-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2}).*$/'; | |
$fields['address_1']['custom_attributes']['data-parsley-error-message'] = __( 'Please enter a valid address.', 'your-translation-domain' ); | |
return $fields; | |
}, | |
100001 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment