Support » Plugin: NIF (Num. de Contribuinte Portugu√™s) for WooCommerce » Required field message even when the field doesn’t appear

  • Resolved josesebastiao



    For international users already registred on the site, the field NIF don’t appear (it’s fine this way), but they can’t finish the checkout because it shows a message telling the field NIF is required.

    I’ve the following code like the cocumentation says:

    add_filter(‘woocommerce_billing_fields’, ‘woocommece_nif_checkout_required’, 11, 2);
    function woocommece_nif_checkout_required($fields, $country) {
    if($country==’PT’) {
    if (isset($fields[‘billing_nif’])) {
    return $fields;

    Can you help please?
    Thank you.
    Best regards

    • This topic was modified 2 years, 12 months ago by josesebastiao.
Viewing 4 replies - 1 through 4 (of 4 total)
  • We’ve just tested that exact same filter and when changing the country, the field stops being required, as you can see:
    We’ve then filled the State and ZIP and the order was accepted.

    The field stays “red” but that’s just because the theme is not updating the class correctly.

    Can you provide a URL?


    The URL is

    In that test the user was already registed in the site? For us when the user is already registed the field don’t appear but it shows the message that the field is required.

    Thank you

    The previous screenshot was of a situation where Portugal was initially chosen and then the country was changed to Paraguay. That’s why the field is still there, but NOT required.

    When getting back to the checkout after changing the country, the field is not there and it’s not required:

    If you remove the filter from your (child-)theme functions.php file does this problem go away? If not, you must be having something else setting the field as required.

    This ticket will be closed due to lack of feedback

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Required field message even when the field doesn’t appear’ is closed to new replies.