How to unset billing fields in woocommerce cart?

Member

by dedrick , in category: PHP CMS , 6 months ago

How to unset billing fields in woocommerce cart?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by ryleigh , 6 months ago

@dedrick 

To unset billing fields in WooCommerce cart, you can use the following code snippet in your theme's functions.php file or in a custom plugin:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
add_filter( 'woocommerce_checkout_fields', 'unset_billing_fields' );

function unset_billing_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['billing']['billing_email'] );
    return $fields;
}


This code will unset the specified billing fields from the checkout page in WooCommerce. You can customize the unset fields list according to your requirements. Once you have added this code snippet, the specified billing fields will no longer be visible on the checkout page.