• Resolved darrylhadfield

    (@darrylhadfield)


    I’ve taken on a gut/upgrade job with a customer. Oddly, in both the staging environment as well as the prod environment, all orders – both from before and after the upgrade – have swapped the Zipcode such that addresses in orders now read:

    Fistname Lastname
    1234 Streetname
    City Zipcode
    State

    Rather than the more expected:

    Fistname Lastname
    1234 Streetname
    City State Zipcode

    Why would this occur?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hello @darrylhadfield ,

    In order to change the position of the fields, you have to change the priority of the fields accordingly.

    i.e,

    billing_first_name 10,
    billing_last_name 20,
    billing_company 30,
    .. and so on each field is differentiated by the difference of 10

    Change the priority that particular filed change it’s position.

    like this,

    add_filter( 'woocommerce_default_address_fields', 'ced_reorder_checkout_fields' );
      
    function ced_reorder_checkout_fields( $fields ) {
     
       // default priorities: 
       // 'first_name' - 10
       // 'last_name' - 20
       // 'company' - 30
       // 'country' - 40
       // 'address_1' - 50
       // 'address_2' - 60
       // 'city' - 70
       // 'state' - 80
       // 'postcode' - 90
      
      // e.g. move 'company' above 'first_name':
      // just assign priority less than 10
      $fields['company']['priority'] = 8;
     
      return $fields;
    }

    Thanks,

    Thread Starter darrylhadfield

    (@darrylhadfield)

    a) Would that go into wp-config, or another file?
    b) I’m a little concerned about adding code as the likelihood of that being overridden in the next update due to file copy activity. Is this not something that is configurable within WC?

    last.. thank you very much – Even if I have to manually add the filter to code, it achieves the desired end result.

    Hello,

    No not in config file, you need to put this in active theme’s functions.php

    No keep it in child theme or it will not wave off, with the update of woo.

    Thanks,

    Thread Starter darrylhadfield

    (@darrylhadfield)

    Thank you -that would suggest then that a theme update would likely overwrite, causing the same issue. Still a better option than current, although I wish WooCommerce had this configurable as an option rather than having to modify other WordPress components.

    Thread Starter darrylhadfield

    (@darrylhadfield)

    I apologize, reading your code again shows that the default is the expected visibility in the order viewing area that my customer (the store proprietor) sees.

    Customers checking out will see fields arrayed in the order per the default, but the oddly shown address (zipcode before state) is when the proprietor views the orders in the control panel.

    That’s what I’m trying to correct, as he uses that as a simple copy/paste for label purposes.

    Plugin Support AW a11n

    (@slash1andy)

    Automattic Happiness Engineer

    Hey there!

    The address on both places should not show like you are saying it does (for US addresses). If it is showing with the zip before state, there’s likely a customization somewhere on your site that is changing that. I would recommend doing a conflict testing (disabling all other plugins, changing themes to default twentytwenty) to figure out if that’s it.

    Thread Starter darrylhadfield

    (@darrylhadfield)

    Good point; thank you very much. Found the problematic plugin and sent them feedback.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘State now appears after zipcode?’ is closed to new replies.