Created
June 14, 2026 06:40
-
-
Save arfinmilondev/c169728bf9243154556c1b1855e02645 to your computer and use it in GitHub Desktop.
woocommerce_checkout_fields_remove
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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