Remove Address Fields in WooCommerce Form Checkout

WooCommerce has the ability to remove the address fields in the checkout form, this is great if you do not require the address fields as you may have a virtual/download only products that don’t require shipping, less fields to fill out = happy customers.

woocommerce-all-address-fields

You can remove address field layouts, so you have just name and email.

woocommerce-all-name-email-fields

This is all done with the woocommerce_billing_fields filter, so in your themes functions.php you can add the following…

<?php
//remove some fields from billing form
//ref - https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
function wpb_custom_billing_fields( $fields = array() ) {
unset($fields['billing_company']);
unset($fields['billing_address_1']);
unset($fields['billing_address_2']);
unset($fields['billing_state']);
unset($fields['billing_city']);
unset($fields['billing_phone']);
unset($fields['billing_postcode']);
unset($fields['billing_country']);
return $fields;
}
add_filter('woocommerce_billing_fields','wpb_custom_billing_fields');
view raw remove-fields.php hosted with ❤ by GitHub
<?php
// Remove some fields from billing form
// Our hooked in function - $fields is passed via the filter!
// Get all the fields - https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/
function custom_override_checkout_fields_ek( $fields ) {
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_state']);
return $fields;
}
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields_ek', 99 );
view raw remove-fields2.php hosted with ❤ by GitHub

So this will remove or unset all the address fields if you want to keep a certain field in just remove the relevant line from the code snippet.

Ref.

2 Comments

  1. Melker Walter on June 28, 2017 at 7:31 am

    Great post, I always prefer coding than using a plugin for customizing woocommerce checkout page. I did also customize my checkout by changing the texts where I made a post here: http://www.22bulbjungle.com/woocommerce-change-text-on-checkout-page-quick-tutorial/

    Great write-up by the way!

  2. miguras on September 4, 2016 at 9:29 pm

    Hello. Great article. I made a plugin that do the same. You can disable/rearrange content inside the single product page and shop page. Also, you can remove checkout fields. I uploaded it to wordpress, so here you have the link WooEnhacer – WooCommerce Customizer if someone is interested.

Leave a Comment





%d bloggers like this: