Skip to content

Instantly share code, notes, and snippets.

@rynaldos-zz
Last active March 24, 2017 11:18
Show Gist options
  • Save rynaldos-zz/31fdcac87f5a88c84bf6 to your computer and use it in GitHub Desktop.
Save rynaldos-zz/31fdcac87f5a88c84bf6 to your computer and use it in GitHub Desktop.
[WooCommerce] Make the EU-VAT field required during checkout (and add asterisk)
add_action('woocommerce_checkout_process', 'wc_force_vat_field_to_be_not_empty');
function wc_force_vat_field_to_be_not_empty() {
// Check if set, if its not set add an error.
if ( ! $_POST['vat_number']);
wc_add_notice( __( 'Please enter your VAT number.' ), 'error' );
}
// adding the asterisk (css)
body.woocommerce-checkout .address-field.vat-number label:after {
content: " *";
color: red;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment