Skip to content

Instantly share code, notes, and snippets.

@arfinmilondev
Created June 14, 2026 06:40
Show Gist options
  • Select an option

  • Save arfinmilondev/c169728bf9243154556c1b1855e02645 to your computer and use it in GitHub Desktop.

Select an option

Save arfinmilondev/c169728bf9243154556c1b1855e02645 to your computer and use it in GitHub Desktop.
woocommerce_checkout_fields_remove
<?php
add_filter( 'woocommerce_checkout_fields', function( $fields ) {
// Remove fields
unset( $fields['billing']['billing_last_name'] );
unset( $fields['billing']['billing_company'] );
unset( $fields['billing']['billing_country'] );
unset( $fields['billing']['billing_address_2'] );
unset( $fields['billing']['billing_city'] );
unset( $fields['billing']['billing_postcode'] );
unset( $fields['billing']['billing_email'] );
unset( $fields['shipping'] );
// Make phone required
$fields['billing']['billing_phone']['required'] = true;
$fields['billing']['billing_phone']['label'] = 'Phone';
return $fields;
});
add_filter( 'woocommerce_checkout_fields', function( $fields ) {
$fields['billing']['billing_state']['default'] = 'TZ02';
return $fields;
});
add_action( 'woocommerce_before_checkout_form', function() {
if ( WC()->customer && empty( WC()->customer->get_billing_state() ) ) {
WC()->customer->set_billing_state( 'TZ02' );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment