Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Matt Harrison

    (@matt-h-1)

    You can customize the WooCommerce address fields and not include the billing email if it is a secondary address with this customization. This will remove the field and it will no longer run validation.

    This customization should do that:

    add_filter( 'woocommerce_billing_fields', function ( $fields ) {
    	if ( isset( $fields['billing_email'] ) && ! empty( $_GET['address-book'] ) ) {
    		unset( $fields['billing_email'] );
    	}
    	return $fields;
    } );

    Depending on what you are trying to do, if you just didn’t want to have customers re-enter email, I would probably do something like this and have it automatically fill out the form with the user’s email address by default.

    add_filter( 'woocommerce_billing_fields', function ( $fields ) {
    	if ( isset( $fields['billing_email'] ) ) {
    		$current_user = wp_get_current_user();
    		if ( ! empty( $current_user ) ) {
    			$fields['billing_email']['default'] = $current_user->user_email;
    		}
    	}
    	return $fields;
    } );
    Thread Starter jagrutiparihar1712

    (@jagrutiparihar1712)

    Hi, Matt Harrison?

    Thank you for this solution it’s working for me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Disabled 2 email option from additional Billing address’ is closed to new replies.