Title: Checkout fields order
Last modified: October 12, 2021

---

# Checkout fields order

 *  Resolved [Oded Talmon](https://wordpress.org/support/users/odedta/)
 * (@odedta)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/checkout-fields-order/)
 * Hello,
    I’m trying to modify & re-order the checkout fields using 3 hooks (all
   with priority 1):
 *     ```
       woocommerce_checkout_fields
       woocommerce_billing_fields
       woocommerce_default_address_fields
       ```
   
 * After all the modifications the $fields in each hook look like this: [https://pastebin.com/QPW4wqiJ](https://pastebin.com/QPW4wqiJ)
 * The fields in checkout look like this: [https://ibb.co/1MPNGVz](https://ibb.co/1MPNGVz)
 * This is the code I’ve used:
 *     ```
       /*
        * Checkout Fields
        */
       function schechter_woocommerce_checkout_fields( $fields ) {
       	unset( $fields['billing']['billing_company'] );
   
       	// Priority
       	$fields['billing']['billing_first_name']['priority'] = 10;
       	$fields['billing']['billing_last_name']['priority']  = 20;
       	$fields['billing']['billing_phone']['priority']      = 30;
       	$fields['billing']['billing_email']['priority']      = 40;
       	$fields['billing']['billing_address_1']['priority']  = 50;
       	$fields['billing']['billing_address_2']['priority']  = 60;
       	$fields['billing']['billing_city']['priority']       = 70;
       	$fields['billing']['billing_country']['priority']    = 80;
       	$fields['billing']['billing_postcode']['priority']   = 90;
   
       	// Placeholders
       	$fields['billing']['billing_country']['placeholder']   = '';
       	$fields['billing']['billing_address_1']['placeholder'] = '';
       	$fields['billing']['billing_address_2']['placeholder'] = '';
       	$fields['order']['order_comments']['placeholder']      = '';
   
       	/*
       	 * Tab Index
       	 */
       	$fields['billing']['billing_first_name']['custom_attributes'] = array(
       		'tabindex' => 1,
       	);
       	$fields['billing']['billing_last_name']['custom_attributes']  = array(
       		'tabindex' => 2,
       	);
       	$fields['billing']['billing_country']['custom_attributes']    = array(
       		'tabindex' => 3,
       	);
       	$fields['billing']['billing_city']['custom_attributes']       = array(
       		'tabindex' => 4,
       	);
       	$fields['billing']['billing_state']['custom_attributes']      = array(
       		'tabindex' => 5,
       	);
       	$fields['billing']['billing_address_1']['custom_attributes']  = array(
       		'tabindex' => 6,
       	);
       	$fields['billing']['billing_address_2']['custom_attributes']  = array(
       		'tabindex' => 7,
       	);
       	$fields['billing']['billing_postcode']['custom_attributes']   = array(
       		'tabindex' => 8,
       	);
       	$fields['billing']['billing_phone']['custom_attributes']      = array(
       		'tabindex' => 9,
       	);
       	$fields['billing']['billing_email']['custom_attributes']      = array(
       		'tabindex' => 10,
       	);
       	$fields['order']['order_comments']['custom_attributes']       = array(
       		'tabindex' => 11,
       		'rows'     => 1,
       	);
   
       	return $fields;
       }
       add_filter( 'woocommerce_checkout_fields', 'schechter_woocommerce_checkout_fields', 1 );
   
       /*
        * Customize billing fields
        */
       function schechter_woocommerce_billing_fields( $billing_fields ) {
       	unset( $billing_fields['billing_company'] );
   
       	// Set labels and placeholders
       	$billing_fields['billing_address_2']['label']       = 'Apartment, suite, unit, etc. (optional)';
       	$billing_fields['billing_address_2']['placeholder'] = '';
       	$billing_fields['billing_address_2']['label_class'] = array();
   
       	// Set the order of the fields
       	$fields_order = array(
       		'first_name',
       		'last_name',
       		'country',
       		'state',
       		'city',
       		'address_1',
       		'address_2',
       		'postcode',
       		'phone',
       		'email',
       	);
   
       	$count    = 1;
       	$priority = 10;
   
       	foreach( $fields_order as $field ) {
       		if( isset( $billing_fields[ 'billing_' . $field ] ) ) {
       			$billing_fields[ 'billing_' . $field ]['priority'] = $count * $priority;
       			$ordered_fields[ 'billing_' . $field ]             = $billing_fields[ 'billing_' . $field ];
       		}
   
       		$count++;
       	}
   
       	return $ordered_fields;
       }
       add_filter( 'woocommerce_billing_fields', 'schechter_woocommerce_billing_fields', 1 );
   
       /*
        * Customize default address fields
        */
       function schechter_woocommerce_default_address_fields( $address_fields ) {
       	unset( $address_fields['company'] );
   
       	// Set labels and placeholders
       	$address_fields['address_2']['label']       = 'Apartment, suite, unit, etc. (optional)';
       	$address_fields['address_2']['placeholder'] = '';
       	$address_fields['address_2']['label_class'] = array();
   
       	// Set the order of the fields
       	$fields_order = array(
       		'first_name',
       		'last_name',
       		'country',
       		'state',
       		'city',
       		'address_1',
       		'address_2',
       		'postcode',
       		'phone',
       		'email',
       	);
   
       	$count    = 1;
       	$priority = 10;
   
       	foreach( $fields_order as $field ) {
       		if( isset( $address_fields[ $field ] ) ) {
       			$address_fields[ $field ]['priority'] = $count * $priority;
       			$ordered_fields[ $field ]             = $address_fields[ $field ];
       		}
   
       		$count++;
       	}
   
       	return $ordered_fields;
       }
       add_filter( 'woocommerce_default_address_fields', 'schechter_woocommerce_default_address_fields', 1 );
       ```
   
 * The order modification is not working, why is that?
 * Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [MayKato](https://wordpress.org/support/users/maykato/)
 * (@maykato)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/checkout-fields-order/#post-14966926)
 * Hello,
 * It looks like you are looking for help with the custom code. I can also recommend
   the following places for more development-oriented questions:
 * WooCommerce Slack Community: [https://woocommerce.com/community-slack/](https://woocommerce.com/community-slack/)
   
   WooCommerce Community on Facebook: [https://www.facebook.com/groups/advanced.woocommerce/](https://www.facebook.com/groups/advanced.woocommerce/)
 * Alternatively, you could use a plugin like [Checkout Field Editor](https://woocommerce.com/products/woocommerce-checkout-field-editor/)
   to rearrange the checkout fields.
    -  This reply was modified 4 years, 7 months ago by [MayKato](https://wordpress.org/support/users/maykato/).
 *  [MayKato](https://wordpress.org/support/users/maykato/)
 * (@maykato)
 * [4 years, 6 months ago](https://wordpress.org/support/topic/checkout-fields-order/#post-14989584)
 * Hi [@odedta](https://wordpress.org/support/users/odedta/)
 * We’ve not heard back from you in a while, so I’m marking this thread as resolved.
   If you have further questions, please feel free to open a new topic.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Checkout fields order’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [MayKato](https://wordpress.org/support/users/maykato/)
 * Last activity: [4 years, 6 months ago](https://wordpress.org/support/topic/checkout-fields-order/#post-14989584)
 * Status: resolved