Skip Navigation

[Resolved] Country code shows up in stead of country name

This thread is resolved. Here is a description of the problem and solution.

Problem:
Country code shows up in stead of country name for WooCommerce billing country field

Solution:
Actully there is no Toolset issue as the country select field is set to save value and select option values are saved as country code not as full country names.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/country-code-shows-up-in-stead-of-country-name/#post-924617

Relevant Documentation:

This support ticket is created 6 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 2 voices.

Last updated by Dido 6 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#924350
countrycode.JPG

Hi,

I am surprised, in stead of the contry name, the country code shows up on my Custom Post.
It is a custom user field from WooCommerce.

see my screenshot with several screens on it.
I hope you understand the screens.

#924489

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - the field must be saved the option value for country as country code.

Could you please share problem URL and access details that will help me to guide you in right direction.

#924617

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please check now: hidden link

Actully there is no Toolset issue as the country select field is set to save value and select option values are saved as country code not as full country names.

I've added following shortcode to your current theme's functions.php file:


function func_show_billing_country( $atts ){
	$code = $atts['code'];
	$countries_obj = new WC_Countries();
	$countries_array = $countries_obj->get_countries();

	// Get the country name:
	return $countries_array[$code];

}
add_shortcode( 'show_billing_country', 'func_show_billing_country' );

And in your content template I've called above shortcode as given under:

[show_billing_country code="[types usermeta='billing_country' user_is_author='true'][/types]"]

I can see on page now full country name is displayed. Could you please confirm.

#924628

Thank you very much Minesh, for helping me out so often.