Skip Navigation

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

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 hace 6 años, 4 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 3 respuestas, tiene 2 mensajes.

Última actualización por Dido hace 6 años, 4 meses.

Asistido por: Minesh.

Autor
Mensajes
#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

Idiomas: Inglés (English )

Zona horaria: 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

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Could you please check now: enlace oculto

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.