Support » Plugin: WooCommerce » remove billing fields in Address in account page

Viewing 4 replies - 1 through 4 (of 4 total)
  • @lukefiretoss) Thanks. Previously, I use this code:

    // Hook in
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    
    // Our hooked in function - $fields is passed via the filter!
    function custom_override_checkout_fields( $fields ) {
         unset($fields['billing']['billing_company']);
    	 unset($fields['billing']['billing_address_1']);
    	 unset($fields['billing']['billing_address_2']);
    	 unset($fields['billing']['billing_country']);
    	 unset($fields['billing']['billing_state']);
    	 unset($fields['billing']['billing_postcode']);
    	 unset($fields['billing']['billing_email']);
         return $fields;
    } 

    But it removes only in checkout page. Now you give direction. Yes, It removes both country fields in checkout page and in address in Account page.

    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    add_filter( 'woocommerce_billing_fields' , 'custom_override_billing_fields' );
    add_filter( 'woocommerce_shipping_fields' , 'custom_override_shipping_fields' );
    
    function custom_override_checkout_fields( $fields ) {
      unset($fields['billing']['billing_country']);
      unset($fields['shipping']['shipping_country']);
      return $fields;
    }
    
    function custom_override_billing_fields( $fields ) {
      unset($fields['billing_country']);
      return $fields;
    }
    
    function custom_override_shipping_fields( $fields ) {
      unset($fields['shipping_country']);
      return $fields;
    }

    BUT actually I want to remove not only Country fields, but Company, Address1, Address2, State, Postcode and Email fields. According to the code you share, now I apply like this but not working.

    /*Remove fields in checkout page and Address in Account pages*/
    
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    add_filter( 'woocommerce_billing_fields' , 'custom_override_billing_fields' );
    add_filter( 'woocommerce_shipping_fields' , 'custom_override_shipping_fields' );
    
    function custom_override_checkout_fields( $fields ) {
      unset($fields['billing']['billing_country']);
      unset($fields['shipping']['shipping_country']);
      unset($fields['billing']['billing_company']);
      unset($fields['shipping']['shipping_company']);
      unset($fields['billing']['billing_address_1']);
      unset($fields['shipping']['shipping_address_1']);
      unset($fields['billing']['billing_address_2']);
      unset($fields['shipping']['shipping_address_2']);
      unset($fields['billing']['billing_state']);
      unset($fields['shipping']['shipping_state']);
      unset($fields['billing']['billing_postcode']);
      unset($fields['shipping']['shipping_postcode']);
      unset($fields['billing']['billing_email']);
      unset($fields['shipping']['shipping_email']);
      return $fields;
    }
    
    function custom_override_billing_fields( $fields ) {
      unset($fields['billing_country']);
      unset($fields['billing']['billing_company']);
      unset($fields['billing']['billing_address_1']);
      unset($fields['billing']['billing_address_2']);
      unset($fields['billing']['billing_state']);
      unset($fields['billing']['billing_postcode']);
      unset($fields['billing']['billing_email']);
      return $fields;
    }
    
    function custom_override_shipping_fields( $fields ) {
      unset($fields['shipping_country']);
      unset($fields['shipping']['shipping_company']);
      unset($fields['shipping']['shipping_address_1']);
      unset($fields['shipping']['shipping_address_2']);
      unset($fields['shipping']['shipping_state']);
      unset($fields['shipping']['shipping_postcode']);
      unset($fields['shipping']['shipping_email']);
      return $fields;
    }

    The question is how can I remove Country, Company, Address1, Address2, State, Postcode and Email fields from both checkout page and in Address in Account page? Sorry, my earlier question may not be clear enough.

    Plugin Support Three Sons

    (@3sonsdevelopment)

    Hi @topsan123,

    Have you tried the method suggested in this Stack Overflow answer?

    https://stackoverflow.com/questions/49641316/customizing-my-account-addresses-fields-in-woocommerce-3/#answer-49641954

    I haven’t tried it myself, but it may be an option for you.

    Best,

    Hello @3sonsdevelopment

    Thanks. But I managed to do it already with this code:

    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
    add_filter( 'woocommerce_billing_fields' , 'custom_override_billing_fields' );
    
    function custom_override_checkout_fields( $fields ) {
      unset($fields['billing']['billing_postcode']);
      unset($fields['billing']['billing_state']);
      unset($fields['billing']['billing_country']);
      unset($fields['billing']['billing_address_1']);	
      return $fields;
    }
    
    function custom_override_billing_fields( $fields ) {
      unset($fields['billing_postcode']);
      unset($fields['billing_state']);
      unset($fields['billing_country']);
      unset($fields['billing_address_1']);
      return $fields;
    }

    This code removes the fields both in checkout page and in Address in Account page.

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