We’ve already seen how to disable fields on the checkout page by using a simple snippet.

Given my ultimate goal of trying to do as much as possible without installing heavy-weight plugins, today we’ll take a look at how to move fields around inside the billing & shipping sections.

WooCommerce: move billing/shipping checkout fields around
WooCommerce: move billing/shipping checkout fields around WooCommerce: move billing/shipping checkout fields around

PHP Snippet: Move / Reorder Fields @ WooCommerce Checkout Page

WooCommerce 3.0 has added a “priority” field to each billing and shipping field. Now moving fields @ checkout is much easier!


/**
 * @snippet       Move / ReOrder Fields @ Checkout Page, WooCommerce version 3.0+
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=19571
 * @author        Rodolfo Melogli
 * @compatible    Woo 3.5.3
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_default_address_fields', 'bbloomer_reorder_checkout_fields' );
 
function bbloomer_reorder_checkout_fields( $fields ) {

	// default priorities: 
	// 'first_name' - 10
	// 'last_name' - 20
	// 'company' - 30
	// 'country' - 40
	// 'address_1' - 50
	// 'address_2' - 60
	// 'city' - 70
	// 'state' - 80
	// 'postcode' - 90
 
  // e.g. move 'company' above 'first_name':
  // just assign priority less than 10
  $fields['company']['priority'] = 8;

  return $fields;
}

PHP Snippet: Move / Reorder Email Field @ WooCommerce Checkout Page


/**
 * @snippet       Move / ReOrder Fields @ Checkout Page, WooCommerce version 3.0+
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=19571
 * @author        Rodolfo Melogli
 * @compatible    Woo 3.5.3
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_filter( 'woocommerce_billing_fields', 'bbloomer_move_checkout_email_field', 10, 1 );

function bbloomer_move_checkout_email_field( $address_fields ) {
    $address_fields['billing_email']['priority'] = 5;
    return $address_fields;
}

Share:

Leave a Reply