WordPress.org

Forums

WooCommerce - excelling eCommerce
[resolved] Change field order on checkout page? (17 posts)

  1. jplacy2
    Member
    Posted 2 years ago #

    I know it's possible to modify fields on the WC checkout page:

    http://wcdocs.woothemes.com/snippets/tutorial-customising-checkout-fields-using-hooks-and-filters/

    ...but what about re-ordering the fields? In the U.S., most checkout forms take the customer info in this order: name, address, city, state, zip. WC reverses zip and state, which can be counter-intuitive for customers. I know I can hack the core code, but I'd prefer to avoid that.

    http://wordpress.org/extend/plugins/woocommerce/

  2. kelseyroth
    Member
    Posted 2 years ago #

    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.

  3. rikardo85
    Member
    Posted 2 years ago #

    I would also like to know how to do this.

  4. Dynadata
    Member
    Posted 2 years ago #

    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

    http://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

  5. jplacy2
    Member
    Posted 2 years ago #

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

  6. leanderbraunschweig
    Member
    Posted 2 years ago #

    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!

  7. oriye
    Member
    Posted 2 years ago #

    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.

  8. leanderbraunschweig
    Member
    Posted 2 years ago #

    functions.php within your template directory.

  9. Dynadata
    Member
    Posted 2 years ago #

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

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

    I am glad this helped people

  10. riyota
    Member
    Posted 1 year ago #

    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

  11. rahyrs
    Member
    Posted 1 year ago #

    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

  12. Devin Walker
    Member
    Posted 1 year ago #

    Great bit of code! Thanks for the help.

  13. Jasemin
    Member
    Posted 1 year ago #

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

    Thanks

  14. Jasemin
    Member
    Posted 1 year ago #

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

    Thanks

  15. titank15
    Member
    Posted 1 year ago #

    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:

  16. titank15
    Member
    Posted 1 year ago #

  17. Jasemin
    Member
    Posted 1 year ago #

    hello,
    please help me if anyone knows. atleast let me know whether that is possible or not

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic