Okay
  Public Ticket #2570989
Italy Tax Field
Closed

Comments

  •  1
    Mectronik started the conversation

    Hello , We to add one more code for ITALIAN customer only . It's a code requested for electronic invoices ( from begin of 2020 ) .

    It should be menaged like the VAT for EU . But We should it on registration for , only if country is ITALY .

    We added it on "Registration Field" but this appear ever , and We don't find the way to do what explained above .

  •  2,218
    WebWizards replied

    Hi Marco,

    The plugin doesn't have this functionality by default. VAT is a special field, there's no way to create other fields like it.


    But if you want, I can give you some JS code to add to functions.php that would set this up.

    This field should be REQUIRED and VISIBLE for ITALY and INVISIBLE for all other countries, correct?

    If you can give me a link to your registration page with this field, it would be even better, I could test directly in the site.


  •  1
    Mectronik replied

    Hi Stefan , if You can send JS code , this is very appreciated .

    Thanks

  •  2,218
    WebWizards replied

    This code should work if you replace fieldInput and fieldContainer with the html input and its container in the form:

    var fieldContainer = jQuery('input[name="b2bking_custom_field_263"]').parent().parent();
    var fieldInput = jQuery('input[name="b2bking_custom_field_263"]');
    showHideRegistrationFieldsItaly();
    jQuery('.b2bking_country_field_selector select').change(showHideRegistrationFieldsItaly);
    jQuery('select#billing_country').change(showHideRegistrationFieldsItaly);
    jQuery('select#b2bking_registration_roles_dropdown').change(showHideRegistrationFieldsItaly);
    function showHideRegistrationFieldsItaly(){
        let selectedRole = jQuery('#b2bking_registration_roles_dropdown').val();
        let roleDisplay = jQuery('#b2bking_registration_roles_dropdown').css('display');
        let hiddenRole = false;
        if (roleDisplay !== 'inline-block' && roleDisplay !== 'block'){
            hiddenRole = true;
        }
        if (hiddenRole === true || fieldContainer.hasClass('b2bking_custom_registration_'+selectedRole) || fieldContainer.hasClass('b2bking_custom_registration_allroles')){
            let selectedCountry = jQuery('.b2bking_country_field_selector select').val();
            if (selectedCountry === undefined){
                selectedCountry = jQuery('select#billing_country').val();
            }
            if (selectedCountry === 'IT'){
                // required and visible
                fieldInput.prop('required', true);
                fieldContainer.css('display', 'block');
            } else {
                // not required and hidden
                fieldInput.removeAttr('required');
                fieldContainer.css('display', 'none');
            }
        } else {
            // not required and hidden
            fieldInput.removeAttr('required');
            fieldContainer.css('display', 'none');
        }
    }
    


    Or if you can share a link to you registration page and which field it is, I can make the code more precise to your site.