• Resolved Anonymous User 15521305

    (@anonymized-15521305)


    Hello, I try to show state names using this code <?php echo get_user_meta( get_current_user_id(), 'billing_state', true ) ?> However, it shows the state code in stead of state name. How can I show state names?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Shaun Kuschel a11n

    (@shaunkuschel)

    Automattic Happiness Engineer

    Hey @topsan123,

    The billing_state will show the localized abbreviation, so echoing it won’t show the full name. Instead, you can use something like the following code to change the display of the State names everywhere on your site:

    https://gist.github.com/shaunkuschel/252c076d111c82bf7c22a35bdc05c407

    Thread Starter Anonymous User 15521305

    (@anonymized-15521305)

    @shaunkuschel

    Thanks for the code. With your code, I can customize the address format plus this code below to display the address in the template I want. It works fine.
    <?php if (!$order->get_formatted_billing_address()) _e( 'N/A', 'woocommerce' ); else echo $order->get_formatted_billing_address(); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display state name instead of state code’ is closed to new replies.