How to: Change State Name to Postal Abbreviation on WooCommerce Checkout Page using Hook

This is another snippet on how to change State name to Postal Abbreviation in WooCommerce programmatically or using Hook, so you can make “Australian Capital Territory” display as “ACT” or “New South Wales” display as “NSW” and so on, while digging I found few in the net with same topic but I can say they don’t know what they’re doing, yaay they touch core file which they should not as it overwrite and wipe the changes every time WooCommerce release new updates.

This is helpful if you want to print mailing labels for your shipments which only accept Postal Abbreviation, so you don’t have to change it manually and search for correct abbreviation just to make sure you got the right one.

So much for that, let’s get started.


Add the below code into your current themes functions.php file

That’s it, Happy Coding ^_^

by Ryan Sutana

  • Thank you for the article and for the filter so that I don’t have to edit plugin files. It works great!

    I was wondering if there was a way to have this only run for the admin Orders area (ship labels, etc), but keeping the full state names in the dropdown on the customer Checkout page? Because once I implement this filter, it changes it to abbreviations in both places.

    Thank you again!

  • Dave

    Thanks for the tutorial. I found there was a syntax error when using the code so here is the code I used

    add_filter( ‘woocommerce_states’, ‘rs_customize_woocommerce_states’ );


    * @desc Update State Name to Postal Abbreviation


    function rs_customize_woocommerce_states() {

    global $states;

    $states[‘AU’] = array(

    ‘ACT’ => __( ‘ACT’, ‘woocommerce’ ),

    ‘NSW’ => __( ‘NSW’, ‘woocommerce’ ),

    ‘NT’ => __( ‘NT’, ‘woocommerce’ ),

    ‘QLD’ => __( ‘QLD’, ‘woocommerce’ ),

    ‘SA’ => __( ‘SA’, ‘woocommerce’ ),

    ‘TAS’ => __( ‘TAS’, ‘woocommerce’ ),

    ‘VIC’ => __( ‘VIC’, ‘woocommerce’ ),

    ‘WA’ => __( ‘WA’, ‘woocommerce’ )


    $states[‘US’] = array(

    ‘AL’ => __( ‘AL’, ‘woocommerce’ ),

    ‘AK’ => __( ‘AK’, ‘woocommerce’ ),

    ‘AZ’ => __( ‘AZ’, ‘woocommerce’ ),

    ‘AR’ => __( ‘AR’, ‘woocommerce’ )


    // you can find lists of states in WooCommerce plugin directory or in /plugins/woocommerce/i18n/states

    return $states;


    • There’s nothing wrong with the code, just remove the “…” it’s too obvious and add second array termination