Access our premium support and let us know your problems, we will help you solve them.

0
No products in the cart.

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: How to disable field in woocommerce checkout page #9458
    blanksuii
    Participant

    Add is_checkout() on your condition then change the fields to billing_address_1 and 2.

    add_filter( 'woocommerce_checkout_fields', 'readonly_billing_account_fields', 25, 1 );
    function readonly_billing_account_fields ( $billing_fields ) {
        // Only my account billing address for logged in users
        if( (is_user_logged_in() && is_account_page()) || is_checkout()){
    
            $readonly = ['readonly' => 'readonly'];
    
            $billing_fields['billing']['billing_address_1']['custom_attributes'] = $readonly;
            $billing_fields['billing']['billing_address_2']['custom_attributes'] = $readonly;
        }
        return $billing_fields;
    }
    
Viewing 1 post (of 1 total)