Remove Checkout field

Total 9 users online

Most users ever online were 338, on 17 Aug 2022 @ 2:17 pm

Remove Checkout field

If you want to remove any field from Woocommerce checkout page you need to use below function.
Be careful, as this change could cause conflicts with other extensions and plugins. Add the following code to your child theme’s functions.php file. Note that pasting the entire code will remove all fields from the checkout page, so be sure to include only the fields you want to remove.

 
/**
Remove all possible fields
**/
function wc_remove_checkout_fields( $fields ) {

// Billing fields
unset( $fields['billing']['billing_company'] );
unset( $fields['billing']['billing_email'] );
unset( $fields['billing']['billing_phone'] );
unset( $fields['billing']['billing_state'] );
unset( $fields['billing']['billing_first_name'] );
unset( $fields['billing']['billing_last_name'] );
unset( $fields['billing']['billing_address_1'] );
unset( $fields['billing']['billing_address_2'] );
unset( $fields['billing']['billing_city'] );
unset( $fields['billing']['billing_postcode'] );

// Shipping fields
unset( $fields['shipping']['shipping_company'] );
unset( $fields['shipping']['shipping_phone'] );
unset( $fields['shipping']['shipping_state'] );
unset( $fields['shipping']['shipping_first_name'] );
unset( $fields['shipping']['shipping_last_name'] );
unset( $fields['shipping']['shipping_address_1'] );
unset( $fields['shipping']['shipping_address_2'] );
unset( $fields['shipping']['shipping_city'] );
unset( $fields['shipping']['shipping_postcode'] );

// Order fields
unset( $fields['order']['order_comments'] );

return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'wc_remove_checkout_fields' );

Note: The Country field is required. If you remove it, orders cannot be completed and your checkout form will give the following error: “Please enter an address to continue.”

Facebook
Twitter
LinkedIn
Pinterest
Reddit
Skype
Telegram
WhatsApp
Email
Print

Add comment:

Need Help? Chat with me
Please accept our privacy policy first to start a conversation.