Created
March 29, 2017 03:01
-
-
Save cryptexvinci/2182728ba74c3c4693c294c3d70bac34 to your computer and use it in GitHub Desktop.
re-order WooCommerce Checkout Fields
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
add_filter( 'woocommerce_checkout_fields', 'custom_move_checkout_fields' ); | |
function custom_move_checkout_fields( $fields ) { | |
// Lets display the email first. You can move these around depending on your needs. | |
$billing_order = array( | |
"billing_email", | |
"billing_first_name", | |
"billing_last_name", | |
"billing_company", | |
"billing_address_1", | |
"billing_address_2", | |
"billing_postcode", | |
"billing_country", | |
"billing_state", | |
"billing_phone" | |
); | |
// This makes sure above orders are maintained. | |
foreach($billing_order as $billing_field) { | |
$billing_fields[$billing_field] = $fields["billing"][$billing_field]; | |
} | |
$fields["billing"] = $billing_fields; | |
// Re-order this according to your need. | |
$shipping_order = array( | |
"shipping_first_name", | |
"shipping_last_name", | |
"shipping_company", | |
"shipping_address_1", | |
"shipping_address_2", | |
"shipping_postcode", | |
"shipping_country", | |
"shipping_city", | |
"shipping_state" | |
); | |
// This makes sure above orders are maintained. | |
foreach($shipping_order as $shipping_field) { | |
$shipping_fields[$shipping_field] = $fields["shipping"][$shipping_field]; | |
} | |
$fields["shipping"] = $shipping_fields; | |
return $fields; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment