Skip Navigation

[Résolu] Country code shows up in stead of country name

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 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.

This topic contains 3 réponses, has 2 voix.

Last updated by Dido Il y a 3 années et 2 mois.

Assigned support staff: Minesh.

Auteur
Publications
#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: Anglais (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: Anglais (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.