Hi @triptikon ,
Thanks for reaching out!
Below is the code snippet to remove address, city, state, and postcode from Billing and Shipping details.
/**
Remove all possible fields
**/
function wc_remove_checkout_fields( $fields ) {
// Billing fields
unset( $fields['billing']['billing_state'] );
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_state'] );
unset( $fields['shipping']['shipping_address_1'] );
unset( $fields['shipping']['shipping_address_2'] );
unset( $fields['shipping']['shipping_city'] );
unset( $fields['shipping']['shipping_postcode'] );
return $fields;
}
add_filter( 'woocommerce_checkout_fields', 'wc_remove_checkout_fields' );
You need to add the code to your child theme’s functions.php
file or via a plugin that allows custom functions to be added, such as the?Code snippets?plugin. Please don’t add custom code directly to your parent theme’s functions.php
file as this will be wiped entirely when you update the theme.
Hope this helps!