I’ve been working recently on a way to disable the billing address in the checkout page of woocommerce when states in not equal to ‘Lima y Callao’

This is what i got for now

$('#billing_state').change(function (){
 if($('#billing_state').val() == 'Lima y Callao'){
            if($('#billing_address_1').prop( "disabled", true )){
            $('#billing_address_1').prop( "disabled", false );
                if($('#billing_address_2').prop( "disabled", true )){
            $('#billing_address_2').prop( "disabled", false );
    } else {
            $('#billing_address_1').attr('disabled', 'disabled').val('');
            $("#billing_address_2").attr('disabled', 'disabled').val('');
            if(!$(this).hasClass("validate-required")) {
            if(!$(this).hasClass("woocommerce-validated")) {

However, it only disables the textfields but doesnt enable when the option Lima y Callao is selected.
What do you think? I am already looking for answers and I’m trying my best to find a solution on my own.

Read more here: Woocommerce – disabling address fields on checkout based on dropdown states


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: