Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

How to reorder WooCommerce checkout billing field appearance? WordPress

  • SOLVED

I'm creating a madlib style checkout form using WooTheme's [[LINK href="http://wcdocs.woothemes.com/snippets/tutorial-customising-checkout-fields-using-actions-and-filters/"]]<em> Customizing checkout fields using actions and filters</em>[[/LINK]].

The current (default) field order is:
first name
last name
company (hidden for me)
<strong>town/city
zipcode
country
state</strong>
email
phone

I want the fields to be in a more natural order for Americans (where I live), so:
first name
last name
company (hidden for me)
<strong>town/city
state
zipcode
country</strong>
email
phone

How can I best do this?

Answers (1)

2013-01-05

Dbranes answers:

Hi, in the <em>form-billing.php</em> template you could try to replace:

<?php foreach ($checkout->checkout_fields['billing'] as $key => $field) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>


with


// order the keys for your custom ordering or delete the ones you don't need
$mybillingfields=array(
"billing_first_name",
"billing_last_name",
"billing_company",
"billing_address_1",
"billing_address_2",
"billing_city",
"billing_state",
"billing_postcode",
"billing_country",
"billing_email",
"billing_phone"
);

<?php foreach ($mybillingfields as $key) : ?>
<?php woocommerce_form_field( $key, $checkout->checkout_fields['billing'][$key], $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>