Join

Remove Fields from WooCommerce Checkout

Don't want to mess with code snippets? Request for this to be a feature of MyListing Pro.

Instructions

  1. Create a new PHP code snippet.
  2. Copy the contents of code snippet below.
  3. Paste the contents into your code snippet.
  4. Review any notes that I’ve provided.
  5. Save and enable the code snippet.
  6. Test.

Snippet

By default, any line that starts with ‘unset’ will remove the corresponding field. Remove each line, starting with ‘unset,’ for any field you wish to keep as part of your checkout.

add_filter("woocommerce_checkout_fields", "mlc_remove_checkout_fields");

function mlc_remove_checkout_fields($fields)
{
    unset($fields["billing"]["billing_first_name"]);
    unset($fields["billing"]["billing_last_name"]);
    unset($fields["billing"]["billing_company"]);
    unset($fields["billing"]["billing_address_1"]);
    unset($fields["billing"]["billing_address_2"]);
    unset($fields["billing"]["billing_city"]);
    unset($fields["billing"]["billing_postcode"]);
    unset($fields["billing"]["billing_country"]);
    unset($fields["billing"]["billing_state"]);
    unset($fields["billing"]["billing_phone"]);
    unset($fields["order"]["order_comments"]);
    unset($fields["billing"]["billing_email"]);
    unset($fields["account"]["account_username"]);
    unset($fields["account"]["account_password"]);
    unset($fields["account"]["account_password-2"]);

    return $fields;
}

As an example, the code snippet below will remove the Billing Phone and Order Comments, while leaving all the other checkout fields.

add_filter("woocommerce_checkout_fields", "mlc_remove_checkout_fields");

function mlc_remove_checkout_fields($fields)
{
    unset($fields["billing"]["billing_phone"]);
    unset($fields["order"]["order_comments"]);

    return $fields;
}