eu vat billing read only

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #115335
    Fabio Tielen
    Participant

    Hello

    We want to make to make the eu vat billing field readonly.
    We have a custom registration process where clients get an invitation from admin and the admin setup all the account information after validating the new client.

    In the checkout the client can change VAT number which we don’t want.

    We are using a code snippet to prevent changing all the fields required, and this works fine except the vat field from your plugin is not changing behaviour.

    We are using this code snippet:

    add_filter( ‘woocommerce_checkout_fields’ , ‘make_fields_readonly’ );
    function make_fields_readonly( $fields ) {
    $fields[‘billing’][‘billing_company’][‘custom_attributes’] = array( ‘readonly’ => ‘readonly’ );
    $fields[‘billing’][‘billing_phone’][‘custom_attributes’] = array( ‘readonly’ => ‘readonly’ );
    $fields[‘billing’][‘billing_eu_vat_number’][‘custom_attributes’] = array( ‘readonly’ => ‘readonly’ );

    return $fields;
    }

    We tried with both billing_eu_vat_number and _billing_eu_vat_number.
    With _billing_eu_vat_number it creates a new empty field on the billing section?

    I also tried setting a higher prio to 1 and 5 but nothing changes either.
    Any clue how we can achieve this please?

    Thanks

    #115458
    Omar Dabbas
    Moderator
    Plugin Support

    Hi Fabio,

    Can you please try this:

    add_filter( 'woocommerce_checkout_fields' , 'make_fields_readonly', 100 );
    function make_fields_readonly( $fields ) {
    $fields['billing']['billing_company']['custom_attributes'] = array( 'readonly' => 'readonly' );
    $fields['billing']['billing_phone']['custom_attributes'] = array( 'readonly' => 'readonly' );
    $fields['billing']['billing_eu_vat_number']['custom_attributes'] = array( 'readonly' => 'readonly' );
    
    return $fields;
    }

    Let me know if you still encounter issues.

    Omar

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.