Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove fields from WooCommerce checkout page.
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_remove_woo_checkout_fields' );
function custom_remove_woo_checkout_fields( $fields ) {
// remove billing 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['billing']['billing_email']);
// remove shipping fields
unset($fields['shipping']['shipping_first_name']);
unset($fields['shipping']['shipping_last_name']);
unset($fields['shipping']['shipping_company']);
unset($fields['shipping']['shipping_address_1']);
unset($fields['shipping']['shipping_address_2']);
unset($fields['shipping']['shipping_city']);
unset($fields['shipping']['shipping_postcode']);
unset($fields['shipping']['shipping_country']);
unset($fields['shipping']['shipping_state']);
// remove order comment fields
unset($fields['order']['order_comments']);
return $fields;
}
@adoWEB-code
Copy link

adoWEB-code commented Oct 2, 2019

hello, i understand how to remove some fields, but please tell, where to save this document in which directory off wordpress ( in filezilla)
thank you

@samediamba
Copy link

samediamba commented Oct 6, 2019

@adoWEB-code
Copy link

adoWEB-code commented Oct 6, 2019

@babakfp
Copy link

babakfp commented Dec 1, 2019

Thanks a lot.

@aramgh
Copy link

aramgh commented Mar 7, 2020

the country field is required. Do not unset country otherwise it will not work
I have unset country and couldn't understand why it's not working :D

Thank you all

@Geethajillu
Copy link

Geethajillu commented Apr 12, 2020

Thank you...

@brianpando
Copy link

brianpando commented Jun 16, 2020

thanks

@babakfp
Copy link

babakfp commented Jun 16, 2020

the country field is required. Do not unset country otherwise it will not work
I have unset country and couldn't understand why it's not working :D

Thank you all

It works for me, with or without country field.

@slowaways
Copy link

slowaways commented Jul 13, 2021

@adoWEB-code https://www.templatemonster.com/help/woocommerce-how-to-remove-checkout-fields.html

It's placed in your theme's functions file

Or the plugin Snippets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment