Viewing 15 replies - 1 through 15 (of 16 total)
  • I’d like to know this as well. I’ve added several fields to the account billing address and would like to re-order them in the correct sequence.

    I would also like to know how to do this.

    I have found a way to re-order the fields in a kind of a long way, but it works.

    add the filter

    add_filter('woocommerce_checkout_fields','reorder_woo_fields'); //changes adres field on the checkout page

    for every field write the ‘$fields2’-line in the order you like

    function reorder_woo_fields($fields) {
    $fields2['billing']['billing_first_name'] = $fields['billing']['billing_first_name'];
    $fields2['billing']['billing_last_name'] = $fields['billing']['billing_last_name'];
    //rest of the fields....
    
    //just copying these (keeps the standard order)
    $fields2['shipping'] = $fields['shipping'];
    $fields2['account'] = $fields['account'];
    $fields2['order'] = $fields['order'];
    
    return $fields2;
    }

    Remember to put EVERY field in the $fields2 or they will not be shown

    https://pastebin.com/400PDwhf for complete code

    There might be an easier way to copy the array and reorder them, but this worked perfectly for me

    Rowan

    Thread Starter jplacy2

    (@jplacy2)

    Awesome, thanks for your note. I’ll give this a try.

    First of all thanks for the code-solution. Be aware that the code over at pastebin carries an error in line 8:

    $fields2['billing']['billing_address_1'] = $fields['billing'][billing_address_1''];

    should read:

    $fields2['billing']['billing_address_1'] = $fields['billing']['billing_address_1'];

    Works fine otherwise!

    I would also like to change the array of the checkout page.
    Can you tell me which file name do I have to look for?
    Please pardon me for this trivial question.

    functions.php within your template directory.

    @leanderbraunschweig Thanks for showing the bug on the pastebin.
    For people who want to use this snippet I have made a new pastebin:
    https://pastebin.com/AXhasAVa

    @oriye You should indeed add this to your functions.php within your chosen theme.

    I am glad this helped people

    Thanks, Dynadata it was really useful. Though I have an related problem.
    The billing and the shipping address shown after the customer has made the order, in the customer details don’t change, and in the email they receive.

    I would like to change them as well.

    Thanks.

    Riyota

    Can this also be used to change the order of field groups?
    I want to put the order list at the top. Then below it goes the address.
    Thanks

    Great bit of code! Thanks for the help.

    Jasemin

    (@jasemin)

    hi
    Is that possible to change the order of whole fields like order notes after billing Address.

    Thanks

    Jasemin

    (@jasemin)

    or Can i just make the custom fields to display below the order review in woocommerce checkout page.

    Thanks

    titank15

    (@titank15)

    This code breaks the create an account function in my checkout page. The error shown is:

    Warning: Invalid argument supplied for foreach() in \html\wp-content\themes\customizr-child\woocommerce\checkout\form-billing.php on line 53

    theme: customizr

    checkout page:

    titank15

    (@titank15)

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Change field order on checkout page?’ is closed to new replies.