Getting country name from country code in WooCommerce
You can access the WC_Countries
class with WC()->countries
. So to get the country name from an order, you must use:
WC()->countries->countries[ $order->shipping_country ];
On WooCommerce 3.0+ you should use:
WC()->countries->countries[ $order->get_shipping_country() ];
If you like to get the state, you need before check if exist, since WooCommerce doesn't include all states, so here what do you need:
$states = WC()->countries->get_states( $order->get_shipping_country() );
$state = ! empty( $states[ $order->get_shipping_state() ] ) ? $states[ $order->get_shipping_state() ] : '';
To get the state name from state code you can use.
WC()->countries->states[$order->billing_country][$order->billing_state];