Last active
November 12, 2017 15:34
-
-
Save aderaaij/f53cc6e8f909bd623708 to your computer and use it in GitHub Desktop.
Customizing Checkout Field Order
http://wordimpress.com/15-woocommerce-code-snippets-im-thankful-for/ Sometimes the default ordering of fields isn’t optimal for your business. You can modify the order the fields appear by customizing the following function:
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', 'reorder_woo_fields' ); | |
function reorder_woo_fields( $fields ) { | |
//move these around in the order you'd like | |
$fields2['billing']['billing_first_name'] = $fields['billing']['billing_first_name']; | |
$fields2['billing']['billing_last_name'] = $fields['billing']['billing_last_name']; | |
$fields2['billing']['billing_company'] = $fields['billing']['billing_company']; | |
$fields2['billing']['billing_address_1'] = $fields['billing']['billing_address_1']; | |
$fields2['billing']['billing_address_2'] = $fields['billing']['billing_address_2']; | |
$fields2['billing']['billing_city'] = $fields['billing']['billing_city']; | |
$fields2['billing']['billing_postcode'] = $fields['billing']['billing_postcode']; | |
$fields2['billing']['billing_state'] = $fields['billing']['billing_state']; | |
$fields2['billing']['billing_country'] = $fields['billing']['billing_country']; | |
$fields2['billing']['billing_email'] = $fields['billing']['billing_email']; | |
$fields2['billing']['billing_phone'] = $fields['billing']['billing_phone']; | |
//just copying these (keeps the standard order) | |
$fields2['shipping'] = $fields['shipping']; | |
$fields2['account'] = $fields['account']; | |
$fields2['order'] = $fields['order']; | |
return $fields2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment