fbpx

Take this and put it in a plugin or in your Child Theme’s “functions.php” file. (Of course you’re using a Child Theme, right?)

function bsn_remove_woo_billing_fields( $fields ) {
	global $woocommerce;
	// if the total is more than 0 then we still need the fields
	if ( 0 != $woocommerce->cart->total ) {
		return $fields;
	}
	// return the regular billing fields if we need shipping fields
	if ( $woocommerce->cart->needs_shipping() ) {
		return $fields;
	}
  // we don't need the billing fields so empty all of them except the email
  unset( $fields['billing_country'] );
  unset( $fields['billing_first_name'] );
  unset( $fields['billing_last_name'] );
  unset( $fields['billing_company'] );
  unset( $fields['billing_address_1'] );
  unset( $fields['billing_address_2'] );
  unset( $fields['billing_city'] );
  unset( $fields['billing_state'] );
  unset( $fields['billing_postcode'] );
  unset( $fields['billing_phone'] );
	return $fields;
}
add_filter( 'woocommerce_billing_fields', 'bsn_remove_woo_billing_fields', 20 );