Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Change order of billing fields on checkout page.
- // From: http://wordpress.stackexchange.com/a/78377
- add_filter('woocommerce_checkout_fields', 'bdd_reorder_billing_fields', 15);
- function bdd_reorder_billing_fields($fields) {
- $order = array(
- 'billing_first_name',
- 'billing_last_name',
- //'billing_company',
- 'billing_address_1',
- 'billing_email',
- 'billing_address_2',
- 'billing_phone',
- 'billing_city',
- 'billing_state',
- 'billing_country',
- 'billing_postcode',
- );
- foreach($order as $field)
- {
- // TODO: Check that $field is in $fields before saving it.
- $ordered_fields[$field] = $fields['billing'][$field];
- }
- $fields['billing'] = $ordered_fields;
- $fields['billing']['billing_first_name']['class'] = array('form-row-first');
- $fields['billing']['billing_last_name']['class'] = array('form-row-last');
- $fields['billing']['billing_address_1']['class'] = array('form-row-first', 'address-field');
- $fields['billing']['billing_email']['class'] = array('form-row-last');
- $fields['billing']['billing_address_2']['class'] = array('form-row-first', 'address-field');
- $fields['billing']['billing_phone']['class'] = array('form-row-last');
- $fields['billing']['billing_city']['class'] = array('form-row-first', 'address-field');
- $fields['billing']['billing_state']['class'] = array('form-row-first', 'address-field');
- $fields['billing']['billing_country']['class'] = array('form-row-first');
- $fields['billing']['billing_postcode']['class'] = array('form-row-first', 'address-field');
- //echo '<!-- FIELDS: '.var_export($fields, true). ' -->';
- return $fields;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement