0

I am trying to change the order of the Woocommerce checkout page fields, but it's not working for me. I have tried the following code:

add_filter( 'woocommerce_default_address_fields', 'bbloomer_move_checkout_fields_woo_3' );
function bbloomer_move_checkout_fields_woo_3( $fields ) {
  $fields['billing']['billing_email']['priority'] = 3;
  return $fields;
}

It change the order for a while and then re-order the fields in the original format after a fraction of second. I don't know what I am doing wrong.

halfer
  • 19,824
  • 17
  • 99
  • 186
Amrinder Singh
  • 5,300
  • 12
  • 46
  • 88
  • Another related thread here (for WC 3+): https://stackoverflow.com/questions/38973024/woocommerce-checkout-conditional-fields-for-different-persons-custom-status/39009245#39009245 – LoicTheAztec Sep 18 '17 at 11:32

1 Answers1

0

In your child theme you can add this code

<?php 
     // 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",
    );
    foreach ($mybillingfields as $key){
        woocommerce_form_field( $key, $checkout->checkout_fields['billing']
    [$key], $checkout->get_value( $key ) );
    } 
?>

Reference

Amrinder Singh
  • 5,300
  • 12
  • 46
  • 88
sagar
  • 590
  • 4
  • 11