Viewing 9 replies - 1 through 9 (of 9 total)
  • You could use a filter to change the order of the items in the address fields array. Your code goes in functions.php for your child theme.

    Info here:
    https://docs.woothemes.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/

    Thread Starter anikoni

    (@anikoni)

    thanks but this only works for checkout fields. But I need it for the address fields in my account…

    Thread Starter anikoni

    (@anikoni)

    I mean there is this woocommerce_default_address_fields filter but they say:

    In specific cases you need to use the woocommerce_default_address_fields filter. This filter is applied to all billing and shipping default fields:

    country
    first_name
    last_name
    company
    address_1
    address_2
    city
    state
    postcode

    So I can not change the position of e.g. the email with it. Very confusing…

    Thread Starter anikoni

    (@anikoni)

    Got it with the above filter. Thanks for the hint!

    For anyone who’s looking for the solution:

    //Change the order of fields on edit my address page
    add_filter("woocommerce_default_address_fields", "order_address_fields");
    
    function order_address_fields($fields) {
    
        $order = array(
            "first_name",
            "last_name",
            "email",
            "company",
            "country",
            "address_1",
            "city",
            "postcode",
        );
        foreach($order as $field)
        {
            $ordered_fields[$field] = $fields[$field];
        }
    
        $fields = $ordered_fields;
        return $fields;
    }

    Hello,

    I want to display address_1 and address_2 next to each other, do you also know how that is possible?

    Regards,
    Joren

    @joren
    Try this custom css. Your theme markup may be different to mine, so if it doesn’t work, please post the url to your site.

    @media (min-width:768px) {
    #billing_address_1_field
    {float:left; width:50%; padding-right:15px}
    #billing_address_2_field
    {float:left; width:50%; margin-top:27px; padding-left:15px; clear:none}
    }

    I already fixed it!
    Thanks a lot though!

    Regards,
    Joren

    Looks like woocommerce_default_address_fields doesn’t work with e-mail and phone fields. When I try to override the default address fields array and sort it like:
    $order = array(
    “company”,
    “address_1”,
    “address_2”,
    “city”,
    “postcode”,
    );
    through woocommerce_default_address_fields filter, email and phone fields are not in array…there must be some other function hooked which is responsible for those two fields…any suggestions?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Change order of address fields on my account page’ is closed to new replies.